Sha256: 4f0d46a59e030e4bbe76c3a47daba1d0841b7d931b068bdc6d8d84624161c736
Contents?: true
Size: 835 Bytes
Versions: 2
Compression:
Stored size: 835 Bytes
Contents
class Oauth::ClientApp < ActiveRecord::Base self.table_name = :opro_client_applications belongs_to :user validates :app_id, :uniqueness => true validates :name, :uniqueness => true alias_attribute :client_id, :app_id alias_attribute :client_secret, :app_secret alias_attribute :secret, :app_secret serialize :permissions, Hash def self.authenticate(app_id, app_secret) where(["app_id = ? AND app_secret = ?", app_id, app_secret]).first end def self.create_with_user_and_name(user, name) create(:user => user, :name => name, :app_id => generate_id, :app_secret => SecureRandom.hex(16)) end def self.generate_id app_id = SecureRandom.hex(16) client_app = where(:app_id => app_id) if client_app.present? generate_id else return app_id end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
opro-0.0.3 | app/models/oauth/client_app.rb |
opro-0.0.2 | app/models/oauth/client_appl.rb |