feat(auth): add session login, logout and bearer middleware
This commit is contained in:
@@ -48,14 +48,18 @@ func (q *Queries) DeleteExpiredSessions(ctx context.Context) (int64, error) {
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const deleteSession = `-- name: DeleteSession :exec
|
||||
const deleteSession = `-- name: DeleteSession :execrows
|
||||
DELETE FROM sessions
|
||||
WHERE token_hash = $1
|
||||
AND expires_at > now()
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteSession(ctx context.Context, tokenHash string) error {
|
||||
_, err := q.db.Exec(ctx, deleteSession, tokenHash)
|
||||
return err
|
||||
func (q *Queries) DeleteSession(ctx context.Context, tokenHash string) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, deleteSession, tokenHash)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const getSessionUserID = `-- name: GetSessionUserID :one
|
||||
|
||||
Reference in New Issue
Block a user