Sha256: ca22c01a853cde03c3c00d9d5e1963bdece23f910b38843713a04c3291af1b49

Contents?: true

Size: 573 Bytes

Versions: 10

Compression:

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

  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

10 entries across 10 versions & 2 rubygems

Version Path
brycesch-devise_oauth2_providable-1.2.8 app/models/devise/oauth2_providable/access_token.rb
brycesch-devise_oauth2_providable-1.2.7 app/models/devise/oauth2_providable/access_token.rb
brycesch-devise_oauth2_providable-1.2.6 app/models/devise/oauth2_providable/access_token.rb
brycesch-devise_oauth2_providable-1.2.5 app/models/devise/oauth2_providable/access_token.rb
devise_oauth2_providable-1.1.1 app/models/devise/oauth2_providable/access_token.rb
devise_oauth2_providable-1.1.0 app/models/devise/oauth2_providable/access_token.rb
devise_oauth2_providable-1.0.5 app/models/devise/oauth2_providable/access_token.rb
devise_oauth2_providable-1.0.4 app/models/devise/oauth2_providable/access_token.rb
devise_oauth2_providable-1.0.3 app/models/devise/oauth2_providable/access_token.rb
devise_oauth2_providable-1.0.2 app/models/devise/oauth2_providable/access_token.rb