Class: Core::Models::OAuth::RefreshToken

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

Overview

A refresh token is used when an access token is expired, to get a new one. It is then recreated for the next expiration.

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:



21
# File 'lib/core/models/oauth/refresh_token.rb', line 21

belongs_to :token, class_name: 'Core::Models::OAuth::AccessToken', inverse_of: :refresh_token

#used_atDateTime

Returns the date and time at which this refresh token has been useds to create a new access token.

Returns:

  • (DateTime)

    the date and time at which this refresh token has been useds to create a new access token.



17
# File 'lib/core/models/oauth/refresh_token.rb', line 17

field :used_at, type: DateTime, default: nil

#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.



14
# File 'lib/core/models/oauth/refresh_token.rb', line 14

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

Instance Method Details

#used?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/core/models/oauth/refresh_token.rb', line 23

def used?
  !used_at.nil? && used_at < DateTime.now
end