Module: Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken::ClassMethods

Defined in:
lib/doorkeeper/orm/active_record/mixins/access_token.rb

Instance Method Summary collapse

Instance Method Details

#active_for(resource_owner) ⇒ ActiveRecord::Relation

Searches for not revoked Access Tokens associated with the specific Resource Owner.

Parameters:

  • resource_owner (ActiveRecord::Base)

    Resource Owner model instance

Returns:

  • (ActiveRecord::Relation)

    active Access Tokens for Resource Owner


43
44
45
# File 'lib/doorkeeper/orm/active_record/mixins/access_token.rb', line 43

def active_for(resource_owner)
  by_resource_owner(resource_owner).where(revoked_at: nil)
end

#not_expiredObject

Returns non-expired and non-revoked access tokens


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/doorkeeper/orm/active_record/mixins/access_token.rb', line 52

def not_expired
  relation = where(revoked_at: nil)

  if supports_expiration_time_math?
    # have not reached the expiration time or it never expires
    relation.where("#{expiration_time_sql} > ?", Time.now.utc).or(
      relation.where(expires_in: nil)
    )
  else
    ::Kernel.warn <<~WARNING.squish
      [DOORKEEPER] Doorkeeper doesn't support expiration time math for your database adapter (#{adapter_name}).
      Please add a class method `custom_expiration_time_sql` for your AccessToken class/mixin to provide a custom
      SQL expression to calculate access token expiration time. See lib/doorkeeper/orm/active_record/mixins/access_token.rb
      for more details.
    WARNING

    relation
  end
end

#refresh_token_revoked_on_use?Boolean

Returns:

  • (Boolean)

47
48
49
# File 'lib/doorkeeper/orm/active_record/mixins/access_token.rb', line 47

def refresh_token_revoked_on_use?
  column_names.include?("previous_refresh_token")
end