Skip to content

Commit

Permalink
Only expire unexpired API keys (#4975)
Browse files Browse the repository at this point in the history
Avoids looping over already expired keys
  • Loading branch information
segiddins authored Aug 27, 2024
1 parent 523af17 commit 0eb3e68
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/api_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ScopeError < RuntimeError; end

def self.expire_all!
transaction do
find_each.all?(&:expire!)
unexpired.find_each.all?(&:expire!)
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def toxic_email_domain
end

def expire_all_api_keys
api_keys.unexpired.expire_all!
api_keys.expire_all!
end

def destroy_associations_for_discard
Expand Down

0 comments on commit 0eb3e68

Please sign in to comment.