fix: rolling session renewal
This commit is contained in:
@@ -15,6 +15,11 @@ SELECT * FROM session WHERE id = ? LIMIT 1;
|
||||
-- name: DeleteSession :exec
|
||||
DELETE FROM session WHERE id = ?;
|
||||
|
||||
-- name: RefreshSession :exec
|
||||
UPDATE session
|
||||
SET expires_at = ?
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: CreateAPIToken :one
|
||||
INSERT INTO api_token (id, user_id, token_hash, name)
|
||||
VALUES (?, ?, ?, ?)
|
||||
|
||||
@@ -124,6 +124,22 @@ func (q *Queries) DeleteSession(ctx context.Context, id string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const refreshSession = `-- name: RefreshSession :exec
|
||||
UPDATE session
|
||||
SET expires_at = ?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
type RefreshSessionParams struct {
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (q *Queries) RefreshSession(ctx context.Context, arg RefreshSessionParams) error {
|
||||
_, err := q.db.ExecContext(ctx, refreshSession, arg.ExpiresAt, arg.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteWatchListEntry = `-- name: DeleteWatchListEntry :exec
|
||||
DELETE FROM watch_list_entry
|
||||
WHERE user_id = ? AND anime_id = ?
|
||||
|
||||
Reference in New Issue
Block a user