0
0
Fork 0

Fix logic in "last used at per application" oauth token list (#32912)

This commit is contained in:
Matt Jankowski 2024-11-15 10:52:37 -05:00 committed by GitHub
parent 297ce9ef44
commit 319109029d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 7 deletions

View file

@ -280,6 +280,15 @@ class User < ApplicationRecord
save!
end
def applications_last_used
Doorkeeper::AccessToken
.where(resource_owner_id: id)
.where.not(last_used_at: nil)
.group(:application_id)
.maximum(:last_used_at)
.to_h
end
def token_for_app(app)
return nil if app.nil? || app.owner != self