Skip to content

Commit

Permalink
Merge pull request #1625 from doorkeeper-gem/fixes/exclude-endless-to…
Browse files Browse the repository at this point in the history
…kens-when-cleaning

Exclude endless access tokens from StaleRecordsCleaner
  • Loading branch information
nbulaj committed Jan 12, 2023
2 parents 93d67dc + 0976a61 commit 254e08e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ User-visible changes worth mentioning.
- [#ID] Add your PR description here.
- [#1622] Drop support for Rubies 2.5 and 2.6
- [#1605] Fix URI validation for Ruby 3.2+.
- [#1625] Exclude endless access tokens from `StaleRecordsCleaner`.

## 5.6.2

Expand Down
7 changes: 5 additions & 2 deletions lib/doorkeeper/orm/active_record/stale_records_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def initialize(base_scope)
def clean_revoked
table = @base_scope.arel_table

@base_scope.where.not(revoked_at: nil)
@base_scope
.where.not(revoked_at: nil)
.where(table[:revoked_at].lt(Time.current))
.in_batches(&:delete_all)
end
Expand All @@ -24,7 +25,9 @@ def clean_revoked
def clean_expired(ttl)
table = @base_scope.arel_table

@base_scope.where(table[:created_at].lt(Time.current - ttl))
@base_scope
.where.not(expires_in: nil)
.where(table[:created_at].lt(Time.current - ttl))
.in_batches(&:delete_all)
end
end
Expand Down

0 comments on commit 254e08e

Please sign in to comment.