class Devise::Strategies::RemoteAuthenticatable

Public Instance Methods

authenticate!() click to toggle source

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

# 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