Class: Client

Inherits:
CouchRest::Model::Base
  • Object
show all
Includes:
Rack::CouchdbOAuth2::Model::Base
Defined in:
lib/couchdb_oauth2/model/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Rack::CouchdbOAuth2::Model::Base

included

Class Method Details

.find_by_env(env) ⇒ Object



25
26
27
28
29
# File 'lib/couchdb_oauth2/model/client.rb', line 25

def self.find_by_env(env)
  request = Rack::OAuth2::Server::Token::Request.new(env)
  client = Client.find(request.client_id)
  client if client && client.secret == request.client_secret
end

Instance Method Details

#identityObject



21
22
23
# File 'lib/couchdb_oauth2/model/client.rb', line 21

def identity
  self['_id']
end

#setupObject



15
16
17
18
19
# File 'lib/couchdb_oauth2/model/client.rb', line 15

def setup
  if self.secret.nil?
    self.secret = ActiveSupport::SecureRandom.base64(64)
  end
end