wakapi: `Error: Unauthorized` when logging in

I’ve updated to 1.2.5 and I’m getting this error after trying to log in: error

Console log on prod=dev
PS D:\Software\WakAPI> .\wakapi.exe                                                                              2020/05/28 03:34:41 main.go:152: Applied 0 migrations!

(D:/wakapi/services/user.go:60)
[2020-05-28 03:34:41]  [0.00ms]  SELECT * FROM "users"  WHERE "users"."id" = 'admin' AND (("users"."id" = 'admin')) ORDER BY "users"."id" ASC LIMIT 1
[1 rows affected or returned ]
2020/05/28 03:34:41 main.go:194: default user 'admin' already existing

(D:/wakapi/main.go:172)
[2020-05-28 03:34:41]  [0.00ms]  UPDATE "heartbeats" SET "language" = 'Vue'  WHERE (language = '') AND (entity LIKE '%.vue')
[0 rows affected or returned ]
2020/05/28 03:34:41 aggregation.go:84: Generating summaries.
2020/05/28 03:34:41 main.go:137: Listening on 127.0.0.1:3000

(D:/wakapi/services/heartbeat.go:73)
[2020-05-28 03:34:41]  [0.00ms]  DELETE FROM "heartbeats"  WHERE (time <= '2020-05-26 00:00:00')
[0 rows affected or returned ]

(D:/wakapi/services/user.go:43)
[2020-05-28 03:34:41]  [0.99ms]  SELECT * FROM "users"
[2 rows affected or returned ]
2020/05/28 03:34:41 heartbeat.go:85: Successfully cleaned up heartbeats older than 2020-05-26 00:00:00 +0100 BST

(D:/wakapi/services/summary.go:154)
[2020-05-28 03:34:42]  sql: Scan error on column index 1, name "to_time": unsupported Scan, storing driver.Value type string into type *time.Time 

(D:/wakapi/services/summary.go:154)
[2020-05-28 03:34:42]  [0.99ms]  SELECT user_id, max(to_time) as to_time FROM "summaries"   GROUP BY user_id
[1 rows affected or returned ]
2020/05/28 03:34:42 aggregation.go:94: sql: Scan error on column index 1, name "to_time": unsupported Scan, storing driver.Value type string into type *time.Time
127.0.0.1 - - [28/May/2020:03:34:44 +0100] "GET / HTTP/1.1" 200 3275
127.0.0.1 - - [28/May/2020:03:34:44 +0100] "GET /assets/app.css HTTP/1.1" 200 89
127.0.0.1 - - [28/May/2020:03:34:44 +0100] "GET /assets/app.js HTTP/1.1" 200 7812

(D:/wakapi/services/user.go:25)
[2020-05-28 03:34:51]  [0.00ms]  SELECT * FROM "users"  WHERE ("users"."id" = 'nickac') ORDER BY "users"."id" ASC LIMIT 1
[1 rows affected or returned ]
127.0.0.1 - - [28/May/2020:03:34:51 +0100] "POST /login HTTP/1.1" 401 3218
127.0.0.1 - - [28/May/2020:03:34:52 +0100] "GET /assets/app.css HTTP/1.1" 200 89
(base) PS D:\Software\WakAPI> .\wakapi.exe                                                                              2020/05/28 03:35:31 main.go:152: Applied 0 migrations!

(D:/wakapi/services/user.go:60)
[2020-05-28 03:35:31]  [0.00ms]  SELECT * FROM "users"  WHERE "users"."id" = 'admin' AND (("users"."id" = 'admin')) ORDER BY "users"."id" ASC LIMIT 1
[1 rows affected or returned ]
2020/05/28 03:35:31 main.go:194: default user 'admin' already existing

(D:/wakapi/main.go:172)
[2020-05-28 03:35:31]  [0.00ms]  UPDATE "heartbeats" SET "language" = 'Vue'  WHERE (language = '') AND (entity LIKE '%.vue')
[0 rows affected or returned ]
2020/05/28 03:35:31 aggregation.go:84: Generating summaries.
2020/05/28 03:35:31 main.go:137: Listening on 127.0.0.1:3000

(D:/wakapi/services/heartbeat.go:73)
[2020-05-28 03:35:32]  [0.00ms]  DELETE FROM "heartbeats"  WHERE (time <= '2020-05-26 00:00:00')
[0 rows affected or returned ]
2020/05/28 03:35:32 heartbeat.go:85: Successfully cleaned up heartbeats older than 2020-05-26 00:00:00 +0100 BST

(D:/wakapi/services/user.go:43)
[2020-05-28 03:35:32]  [1.99ms]  SELECT * FROM "users"
[1 rows affected or returned ]

(D:/wakapi/services/summary.go:154)
[2020-05-28 03:35:32]  sql: Scan error on column index 1, name "to_time": unsupported Scan, storing driver.Value type string into type *time.Time 

(D:/wakapi/services/summary.go:154)
[2020-05-28 03:35:32]  [0.99ms]  SELECT user_id, max(to_time) as to_time FROM "summaries"   GROUP BY user_id
[1 rows affected or returned ]
2020/05/28 03:35:32 aggregation.go:94: sql: Scan error on column index 1, name "to_time": unsupported Scan, storing driver.Value type string into type *time.Time

(D:/wakapi/services/user.go:25)
[2020-05-28 03:35:37]  [0.00ms]  SELECT * FROM "users"  WHERE ("users"."id" = 'nickac') ORDER BY "users"."id" ASC LIMIT 1
[0 rows affected or returned ]
127.0.0.1 - - [28/May/2020:03:35:37 +0100] "POST /login HTTP/1.1" 404 3217
127.0.0.1 - - [28/May/2020:03:35:37 +0100] "GET /assets/app.css HTTP/1.1" 200 89
127.0.0.1 - - [28/May/2020:03:35:46 +0100] "GET /signup HTTP/1.1" 200 4182
127.0.0.1 - - [28/May/2020:03:35:46 +0100] "GET /assets/app.css HTTP/1.1" 200 89
127.0.0.1 - - [28/May/2020:03:35:46 +0100] "GET /assets/app.js HTTP/1.1" 200 7812

(D:/wakapi/services/user.go:60)
[2020-05-28 03:36:00]  [0.00ms]  SELECT * FROM "users"  WHERE "users"."id" = 'nickac' AND (("users"."id" = 'nickac')) ORDER BY "users"."id" ASC LIMIT 1
[0 rows affected or returned ]

(D:/wakapi/services/user.go:60)
[2020-05-28 03:36:00]  [0.99ms]  INSERT  INTO "users" ("id","api_key","password") VALUES ('nickac','9afd5aa7-317e-4776-ba65-33dfae31d5b3','$2a$10$0dU6ANzVi.T6xZpt5XE5Ke1qXetFWSaY18QKaRXOcG06ftjRLmJve')
[1 rows affected or returned ]
127.0.0.1 - - [28/May/2020:03:36:00 +0100] "POST /signup HTTP/1.1" 302 0
127.0.0.1 - - [28/May/2020:03:36:00 +0100] "GET /?success=account+created+successfully HTTP/1.1" 200 3025
127.0.0.1 - - [28/May/2020:03:36:00 +0100] "GET /assets/app.css HTTP/1.1" 200 89

(D:/wakapi/services/user.go:25)
[2020-05-28 03:36:11]  [0.00ms]  SELECT * FROM "users"  WHERE ("users"."id" = 'nickac') ORDER BY "users"."id" ASC LIMIT 1
[1 rows affected or returned ]
127.0.0.1 - - [28/May/2020:03:36:11 +0100] "POST /login HTTP/1.1" 401 3218
127.0.0.1 - - [28/May/2020:03:36:11 +0100] "GET /assets/app.css HTTP/1.1" 200 89

(D:/wakapi/services/user.go:25)
[2020-05-28 03:36:19]  [0.00ms]  SELECT * FROM "users"  WHERE ("users"."id" = 'nickac') ORDER BY "users"."id" ASC LIMIT 1
[1 rows affected or returned ]
127.0.0.1 - - [28/May/2020:03:36:19 +0100] "POST /login HTTP/1.1" 302 0
127.0.0.1 - - [28/May/2020:03:36:19 +0100] "GET /summary HTTP/1.1" 302 43
127.0.0.1 - - [28/May/2020:03:36:19 +0100] "GET /?error=unauthorized HTTP/1.1" 401 3211
127.0.0.1 - - [28/May/2020:03:36:19 +0100] "GET /assets/app.css HTTP/1.1" 200 89

The user exists on the database user on database

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

Hey @NickAcPT, sorry for the inconveniences! I made changes to the authentication logic recently, which are apparently causing problems in your case. To any other Wakapi users reading this, do you face similar problems as well? Please comment 🙂.

From what I’ve seen from the logs, you have create a new nickac user and try to log in as it, right? Was that user existing before and you deleted it or did you use the admin user prior to the upgrade?

Please also let me how:

  • Which database are you using?
  • Did you set the WAKAPI_PASSWORD_SALT variable in .env?

Let’s try to get this fixed, so you can continue using Wakapi asap 😉

Btw., I’m planning to offer a free, cloud-hosted Wakapi server soon. Would you be interested in using such?