Skip to content

Commit

Permalink
fix: add index on (session_id, revoked) in refresh_tokens (#765)
Browse files Browse the repository at this point in the history
  • Loading branch information
hf committed Oct 21, 2022
1 parent 3332072 commit 5ba3aca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create index if not exists refresh_tokens_session_id_revoked_idx on {{ index .Options "Namespace" }}.refresh_tokens (session_id, revoked);
2 changes: 1 addition & 1 deletion models/refresh_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func RevokeTokenFamily(tx *storage.Connection, token *RefreshToken) error {
var err error
tablename := (&pop.Model{Value: RefreshToken{}}).TableName()
if token.SessionId != nil {
err = tx.RawQuery(`update `+tablename+` set revoked = true where session_id = ?;`, token.SessionId).Exec()
err = tx.RawQuery(`update `+tablename+` set revoked = true where session_id = ? and revoked = false;`, token.SessionId).Exec()
} else {
err = tx.RawQuery(`
with recursive token_family as (
Expand Down

0 comments on commit 5ba3aca

Please sign in to comment.