Sha256: 2514fc0fa79503480d22b0e10f37a7d14a23cb88eddcd306c894ad9f225b56f5

Contents?: true

Size: 694 Bytes

Versions: 1

Compression:

Stored size: 694 Bytes

Contents

module Doorkeeper
  class Application
    include Doorkeeper::OAuth::Helpers


    validates :name, :secret, :redirect_uri, :presence => true
    validates :redirect_uri, :redirect_uri => true

    before_create :generate_uid, :generate_secret

    def self.model_name
      ActiveModel::Name.new(self, Doorkeeper, 'Application')
    end

    def self.authenticate(uid, secret)
      self.where(:uid => uid, :secret => secret).first
    end

    def self.by_uid(uid)
      find_by_id(uid)
    end

    private

    def generate_uid
      self.id = UniqueToken.generate
    end

    def generate_secret
      self.secret = UniqueToken.generate
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
couchkeeper-0.6.7 lib/doorkeeper/models/application.rb