Class: Devise::Strategies::Authenticatable

Inherits:
Base
  • Object
show all
Defined in:
lib/devise/strategies/authenticatable.rb

Overview

Default strategy for signing in a user, based on his email and password. Redirects to sign_in page if it’s not authenticated

Instance Method Summary collapse

Methods inherited from Base

#mapping, #valid?

Instance Method Details

#authenticate!Object

Authenticate a user based on email and password params, returning to warden success and the authenticated user if everything is okay. Otherwise redirect to sign in page.

Please notice the semantic difference between calling fail! and throw :warden. The first does not perform any action when calling authenticate, just when authenticate! is invoked. The second always perform the action.



14
15
16
17
18
19
20
21
# File 'lib/devise/strategies/authenticatable.rb', line 14

def authenticate!
  if valid_attributes? && resource = mapping.to.authenticate(attributes)
    success!(resource)
  else
    store_location
    fail!(:unauthenticated)
  end
end