Class: Devise::Strategies::Rememberable

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

Overview

Remember the user through the remember token. This strategy is responsible to verify whether there is a cookie with the remember token, and to recreate the user from this cookie if it exists. Must be called before authenticatable.

Instance Method Summary collapse

Methods inherited from Base

#mapping

Instance Method Details

#authenticate!Object

To authenticate a user we deserialize the cookie and attempt finding the record in the database. If the attempt fails, we pass to another strategy handle the authentication.



17
18
19
20
21
22
23
# File 'lib/devise/strategies/rememberable.rb', line 17

def authenticate!
  if resource = mapping.to.serialize_from_cookie(remember_me_cookie)
    success!(resource)
  else
    pass
  end
end

#valid?Boolean

A valid strategy for rememberable needs a remember token in the cookies.

Returns:

  • (Boolean)


10
11
12
# File 'lib/devise/strategies/rememberable.rb', line 10

def valid?
  super && remember_me_cookie.present?
end