Module: DoorkeeperMongodb::Mixins::Mongoid::AccessTokenMixin

Extended by:
ActiveSupport::Concern
Includes:
Doorkeeper::Models::Accessible, Doorkeeper::Models::Expirable, Doorkeeper::Models::Revocable, Doorkeeper::Models::Scopes, Doorkeeper::OAuth::Helpers, BaseMixin
Included in:
Doorkeeper::AccessToken
Defined in:
lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#acceptable?(scopes) ⇒ Boolean

Indicates if token is acceptable for specific scopes.

Parameters:

  • scopes (Array<String>)

    scopes

Returns:

  • (Boolean)

    true if record is accessible and includes scopes or false in other cases



229
230
231
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 229

def acceptable?(scopes)
  accessible? && includes_scope?(*scopes)
end

#as_json(_options = {}) ⇒ Hash

JSON representation of the Access Token instance.

Returns:

  • (Hash)

    hash with token data



200
201
202
203
204
205
206
207
208
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 200

def as_json(_options = {})
  {
    resource_owner_id: resource_owner_id,
    scopes: scopes,
    expires_in_seconds: expires_in_seconds,
    application: {uid: application.try(:uid)},
    created_at: created_at.to_i
  }
end

#same_credential?(access_token) ⇒ Boolean

Indicates whether the token instance have the same credential as the other Access Token.

Parameters:

Returns:

  • (Boolean)

    true if credentials are same of false in other cases



217
218
219
220
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 217

def same_credential?(access_token)
  application_id == access_token.application_id &&
    resource_owner_id == access_token.resource_owner_id
end

#token_typeObject

Access Token type: Bearer.



188
189
190
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 188

def token_type
  'bearer'
end

#use_refresh_token?Boolean

Returns:

  • (Boolean)


192
193
194
195
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 192

def use_refresh_token?
  @use_refresh_token ||= false
  !!@use_refresh_token
end