Sha256: 0e2ab9b016c902175fb1bb7d7c67a68ee4a0257b1f35237b3bb123a4d7fc6ec9

Contents?: true

Size: 814 Bytes

Versions: 9

Compression:

Stored size: 814 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", :inverse_of => :access_grants

    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

9 entries across 9 versions & 1 rubygems

Version Path
doorkeeper-0.6.7 lib/doorkeeper/models/access_grant.rb
doorkeeper-0.6.6 lib/doorkeeper/models/access_grant.rb
doorkeeper-0.6.5 lib/doorkeeper/models/access_grant.rb
doorkeeper-0.6.4 lib/doorkeeper/models/access_grant.rb
doorkeeper-0.6.3 lib/doorkeeper/models/access_grant.rb
doorkeeper-0.6.2 lib/doorkeeper/models/access_grant.rb
doorkeeper-0.6.1 lib/doorkeeper/models/access_grant.rb
doorkeeper-0.6.0 lib/doorkeeper/models/access_grant.rb
doorkeeper-0.6.0.rc1 lib/doorkeeper/models/access_grant.rb