module Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken::ClassMethods

Public Instance Methods

active_for(resource_owner) click to toggle source

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

@param resource_owner [ActiveRecord::Base]

Resource Owner model instance

@return [ActiveRecord::Relation]

active Access Tokens for Resource Owner
# File lib/doorkeeper/orm/active_record/mixins/access_token.rb, line 39
def active_for(resource_owner)
  by_resource_owner(resource_owner).where(revoked_at: nil)
end
not_expired() click to toggle source

Returns non-expired and non-revoked access tokens

# File lib/doorkeeper/orm/active_record/mixins/access_token.rb, line 48
      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?() click to toggle source
# File lib/doorkeeper/orm/active_record/mixins/access_token.rb, line 43
def refresh_token_revoked_on_use?
  column_names.include?("previous_refresh_token")
end

Private Instance Methods

compute_doorkeeper_table_name() click to toggle source
# File lib/doorkeeper/orm/active_record/mixins/access_token.rb, line 70
def compute_doorkeeper_table_name
  table_name = "oauth_access_token"
  table_name = table_name.pluralize if pluralize_table_names
  "#{table_name_prefix}#{table_name}#{table_name_suffix}"
end