File cleanup/organization in controllers/concerns
(#27846)
This commit is contained in:
parent
0530ce5e95
commit
1f1c75bba5
22 changed files with 26 additions and 26 deletions
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Api::AccessTokenTrackingConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
ACCESS_TOKEN_UPDATE_FREQUENCY = 24.hours.freeze
|
||||
|
||||
included do
|
||||
before_action :update_access_token_last_used
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_access_token_last_used
|
||||
doorkeeper_token.update_last_used(request) if access_token_needs_update?
|
||||
end
|
||||
|
||||
def access_token_needs_update?
|
||||
doorkeeper_token.present? && (doorkeeper_token.last_used_at.nil? || doorkeeper_token.last_used_at < ACCESS_TOKEN_UPDATE_FREQUENCY.ago)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue