Class: Core::Models::OAuth::AccessToken

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/core/models/oauth/access_token.rb

Overview

An access token is the value assigned to the application to access the data the user is allowed to access.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorizationCore::Models::OAuth::Authorization

Returns the authorization code that issued this token to the application for this user.

Returns:



19
# File 'lib/core/models/oauth/access_token.rb', line 19

belongs_to :authorization, class_name: 'Core::Models::OAuth::Authorization', inverse_of: :tokens, optional: true

#generatedCore::Models::OAuth::AccessToken

Returns the token that has been generated by the current one.

Returns:



26
# File 'lib/core/models/oauth/access_token.rb', line 26

has_one :generated, class_name: 'Core::Models::OAuth::AccessToken', inverse_of: :generator

#generatorCore::Models::Oauth::AccessToken

Returns the token that generated this one.

Returns:

  • (Core::Models::Oauth::AccessToken)

    the token that generated this one.



22
# File 'lib/core/models/oauth/access_token.rb', line 22

belongs_to :generator, class_name: 'Core::Models::OAuth::AccessToken', inverse_of: :generated, optional: true

#valueString

Returns the value of the token, returned to the application when built.

Returns:

  • (String)

    the value of the token, returned to the application when built.



15
# File 'lib/core/models/oauth/access_token.rb', line 15

field :value, type: String, default: ->{ SecureRandom.hex }

Instance Method Details

#premiumObject



38
39
40
# File 'lib/core/models/oauth/access_token.rb', line 38

def premium
  authorization.application.premium
end

#scopesArray<Core::Models::OAuth::Scope>

Returns the scopes this access token can use to access the application

Returns:



34
35
36
# File 'lib/core/models/oauth/access_token.rb', line 34

def scopes
  premium ? Core::Models::OAuth::Scope.all.to_a : authorization.scopes
end