Sha256: 7044bb5c30d1d87548e1034eab4eea16ce0bcc5a72a3a5a46e21ee99cffc4dfb

Contents?: true

Size: 607 Bytes

Versions: 5

Compression:

Stored size: 607 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 :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

5 entries across 5 versions & 2 rubygems

Version Path
mustwin_devise_oauth2_providable-1.1.6 app/models/devise/oauth2_providable/access_token.rb
mustwin_devise_oauth2_providable-1.1.5 app/models/devise/oauth2_providable/access_token.rb
mustwin_devise_oauth2_providable-1.1.4 app/models/devise/oauth2_providable/access_token.rb
mustwin_devise_oauth2_providable-1.1.3 app/models/devise/oauth2_providable/access_token.rb
devise_oauth2_providable-1.1.2 app/models/devise/oauth2_providable/access_token.rb