diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a0c5e40a..f8d52e9f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ User-visible changes worth mentioning. ## main -Add your entry here. +- [#1690] Consider expires_in when clear expired tokens with StaleRecordsCleaner. - [#1747] Fix unknown pkce method error when configured ## 5.8.0 diff --git a/lib/doorkeeper/orm/active_record/stale_records_cleaner.rb b/lib/doorkeeper/orm/active_record/stale_records_cleaner.rb index 3ba6bd590..275e0bc16 100644 --- a/lib/doorkeeper/orm/active_record/stale_records_cleaner.rb +++ b/lib/doorkeeper/orm/active_record/stale_records_cleaner.rb @@ -28,6 +28,7 @@ def clean_expired(ttl) @base_scope .where.not(expires_in: nil) .where(table[:created_at].lt(Time.current - ttl)) + .where(table[:created_at] + table[:expires_in].lt(Time.current)) .in_batches(&:delete_all) end end