Sha256: 7689f5b6e3f85f0712d31ac0716192068b0f70e400e0551b6200774d3d23df81

Contents?: true

Size: 623 Bytes

Versions: 4

Compression:

Stored size: 623 Bytes

Contents

class Devise::Oauth2Providable::AccessToken < ActiveRecord::Base
  expires_according_to :access_token_expires_in

  before_validation :restrict_expires_at, :on => :create, :if => :refresh_token
  belongs_to :refresh_token

  attr_accessible :user, :client, :refresh_token

  def token_response
    response = {
      :access_token => token,
      :token_type => 'bearer',
      :expires_in => expires_in
    }
    response[:refresh_token] = refresh_token.token if refresh_token
    response
  end

  private

  def restrict_expires_at
    self.expires_at = [self.expires_at, refresh_token.expires_at].compact.min
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
anjlab-devise-oauth2-providable-1.1.3 app/models/devise/oauth2_providable/access_token.rb
anjlab-devise-oauth2-providable-1.1.2 app/models/devise/oauth2_providable/access_token.rb
anjlab-devise-oauth2-providable-1.1.1 app/models/devise/oauth2_providable/access_token.rb
anjlab-devise-oauth2-providable-1.1.0 app/models/devise/oauth2_providable/access_token.rb