feat: update service session's tokens
This commit is contained in:
@ -393,3 +393,27 @@ func (q *Queries) UpdateServiceSessionLastActive(ctx context.Context, id uuid.UU
|
||||
_, err := q.db.Exec(ctx, updateServiceSessionLastActive, id)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateServiceSessionTokens = `-- name: UpdateServiceSessionTokens :exec
|
||||
UPDATE service_sessions
|
||||
SET access_token_id = $2, refresh_token_id = $3, expires_at = $4
|
||||
WHERE id = $1
|
||||
AND is_active = TRUE
|
||||
`
|
||||
|
||||
type UpdateServiceSessionTokensParams struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
AccessTokenID *uuid.UUID `json:"access_token_id"`
|
||||
RefreshTokenID *uuid.UUID `json:"refresh_token_id"`
|
||||
ExpiresAt *time.Time `json:"expires_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateServiceSessionTokens(ctx context.Context, arg UpdateServiceSessionTokensParams) error {
|
||||
_, err := q.db.Exec(ctx, updateServiceSessionTokens,
|
||||
arg.ID,
|
||||
arg.AccessTokenID,
|
||||
arg.RefreshTokenID,
|
||||
arg.ExpiresAt,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
@ -46,6 +46,12 @@ SET last_active = NOW()
|
||||
WHERE id = $1
|
||||
AND is_active = TRUE;
|
||||
|
||||
-- name: UpdateServiceSessionTokens :exec
|
||||
UPDATE service_sessions
|
||||
SET access_token_id = $2, refresh_token_id = $3, expires_at = $4
|
||||
WHERE id = $1
|
||||
AND is_active = TRUE;
|
||||
|
||||
-- name: ListAllServiceSessions :many
|
||||
SELECT * FROM service_sessions
|
||||
ORDER BY issued_at DESC
|
||||
|
Reference in New Issue
Block a user