Class: Devise::Strategies::Cocable
- Inherits:
-
Authenticatable
- Object
- Authenticatable
- Devise::Strategies::Cocable
- Defined in:
- lib/devise/strategies/cocable.rb
Overview
The cocable strategy will look for a user in two places: in a domain cookie set by one of our peers and verified by an upstream app or in credentials supplied to us and verified by an upstream app
(If the credentials matched locally, we wouldn’t usually get to this strategy)
Instance Method Summary collapse
Instance Method Details
#authenticate! ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/devise/strategies/cocable.rb', line 17 def authenticate! resource = nil response = nil if authentication_hash response = delegate(authentication_hash) else response = delegate({:auth_token => .token}) end if response resource = mapping.to.where(:uid => response[:uid]).first_or_create resource.update_attributes(response.except(:uid)) end success!(resource) if resource# && validate(resource) end |
#delegate(credentials) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/devise/strategies/cocable.rb', line 35 def delegate(credentials) response = nil Coca.masters.each do |master| response = master.authenticate(scope, credentials) break if response end response end |
#valid? ⇒ Boolean
13 14 15 |
# File 'lib/devise/strategies/cocable.rb', line 13 def valid? valid_for_params_auth? || .valid? end |