fix: delete all sessions on password change (#4659)

- Prevent users from reusing their old password
  as their new password.
This commit is contained in:
Jon Ayers
2022-10-19 21:12:03 -05:00
committed by GitHub
parent ea156cce2e
commit 7a5ae1e552
6 changed files with 117 additions and 3 deletions

View File

@ -145,6 +145,18 @@ func (q *sqlQuerier) DeleteAPIKeyByID(ctx context.Context, id string) error {
return err
}
const deleteAPIKeysByUserID = `-- name: DeleteAPIKeysByUserID :exec
DELETE FROM
api_keys
WHERE
user_id = $1
`
func (q *sqlQuerier) DeleteAPIKeysByUserID(ctx context.Context, userID uuid.UUID) error {
_, err := q.db.ExecContext(ctx, deleteAPIKeysByUserID, userID)
return err
}
const getAPIKeyByID = `-- name: GetAPIKeyByID :one
SELECT
id, hashed_secret, user_id, last_used, expires_at, created_at, updated_at, login_type, lifetime_seconds, ip_address, scope