From a95bbcb6ebf00581ce0d5033e9c2ca9affcdfece Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 9 Nov 2025 19:27:15 +0100 Subject: [PATCH] Fix `last_seen` update on auth --- auth/dbc/users.sql.go | 2 +- auth/sql/queries/users.sql | 2 +- auth/tests/invalid-password.hurl | 4 ++-- auth/users.go | 3 +++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/auth/dbc/users.sql.go b/auth/dbc/users.sql.go index 1426d231..701e171c 100644 --- a/auth/dbc/users.sql.go +++ b/auth/dbc/users.sql.go @@ -259,7 +259,7 @@ const touchUser = `-- name: TouchUser :exec update keibi.users set - last_used = now()::timestamptz + last_seen = now()::timestamptz where pk = $1 ` diff --git a/auth/sql/queries/users.sql b/auth/sql/queries/users.sql index bc888803..292d6d3d 100644 --- a/auth/sql/queries/users.sql +++ b/auth/sql/queries/users.sql @@ -47,7 +47,7 @@ limit 1; update keibi.users set - last_used = now()::timestamptz + last_seen = now()::timestamptz where pk = $1; diff --git a/auth/tests/invalid-password.hurl b/auth/tests/invalid-password.hurl index 7817a09a..c9fde22b 100644 --- a/auth/tests/invalid-password.hurl +++ b/auth/tests/invalid-password.hurl @@ -19,7 +19,7 @@ GET {{host}}/users/me Authorization: Bearer {{jwt}} HTTP 200 [Captures] -register_info: body +register_id: jsonpath "$.id" [Asserts] jsonpath "$.username" == "login-user" @@ -48,7 +48,7 @@ Authorization: Bearer {{jwt}} HTTP 200 [Asserts] jsonpath "$.username" == "login-user" -body == {{register_info}} +jsonpath "$.id" == {{register_id}} # Invalid password login diff --git a/auth/users.go b/auth/users.go index 81a75c5d..29acf3f1 100644 --- a/auth/users.go +++ b/auth/users.go @@ -190,6 +190,9 @@ func (h *Handler) GetMe(c echo.Context) error { if err != nil { return err } + if len(dbuser) == 0 { + return c.JSON(403, "Invalid jwt token, couldn't find user.") + } user := MapDbUser(&dbuser[0].User) for _, oidc := range dbuser {