Class: Devise::Strategies::RemoteAuthenticatable

Inherits:
Authenticatable
  • Object
show all
Defined in:
lib/devise/strategies/remote_authenticatable.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object

For an example check : github.com/plataformatec/devise/blob/master/lib/devise/strategies/database_authenticatable.rb Method called by warden to authenticate a resource.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/devise/strategies/remote_authenticatable.rb', line 11

def authenticate!
  # authentication_hash doesn't include the password
  auth_params = params[scope]


  # mapping.to is a wrapper over the resource model
  resource = mapping.to.new.remote_authentication(auth_params)

  return fail! unless resource

  # remote_authentication method is defined in Devise::Models::RemoteAuthenticatable
  #
  # validate is a method defined in Devise::Strategies::Authenticatable. It takes
  # a block which must return a boolean value.
  #
  # If the block returns true the resource will be loged in
  # If the block returns false the authentication will fail!
  if validate(resource) { resource.password_valid }
    success!(resource)
  end
end