Sha256: 8935e4decad4041008b05a1ec8ef697e9dcfde8f40ec2e7a8ee6b9bc5b2d626e

Contents?: true

Size: 783 Bytes

Versions: 2

Compression:

Stored size: 783 Bytes

Contents

module Doorkeeper
  class AccessGrant
    include Doorkeeper::OAuth::Helpers
    include Doorkeeper::Models::Expirable
    include Doorkeeper::Models::Revocable
    include Doorkeeper::Models::Accessible
    include Doorkeeper::Models::Scopes

    belongs_to :application, :class_name => "Doorkeeper::Application"

    attr_accessible :resource_owner_id, :application_id, :expires_in, :redirect_uri, :scopes

    validates :resource_owner_id, :application_id, :token, :expires_in, :redirect_uri, :presence => true
    validates :token, :uniqueness => true

    before_validation :generate_token, :on => :create

    def self.authenticate(token)
      where(:token => token).first
    end

    private

    def generate_token
      self.token = UniqueToken.generate
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
doorkeeper-0.5.0 lib/doorkeeper/models/access_grant.rb
doorkeeper-0.5.0.rc1 lib/doorkeeper/models/access_grant.rb