feat: automatic termination of older sessions on login (temporary until release 4);

fix: login controller method not returning tokens
This commit is contained in:
2025-07-06 14:45:36 +03:00
parent 8588a17928
commit 72a512bb4f
3 changed files with 23 additions and 8 deletions

View File

@@ -664,6 +664,18 @@ func (q *Queries) PruneTerminatedSessions(ctx context.Context) error {
return err
}
const terminateAllSessionsForUserByUsername = `-- name: TerminateAllSessionsForUserByUsername :exec
UPDATE sessions
SET terminated = TRUE
FROM users
WHERE sessions.user_id = users.id AND users.username = $1::text
`
func (q *Queries) TerminateAllSessionsForUserByUsername(ctx context.Context, username string) error {
_, err := q.db.Exec(ctx, terminateAllSessionsForUserByUsername, username)
return err
}
const updateBannedUser = `-- name: UpdateBannedUser :exec
UPDATE banned_users
SET