Module: Devise::Controllers::Rememberable
- Included in:
- Hooks::Proxy
- Defined in:
- lib/devise/controllers/rememberable.rb
Overview
A module that may be optionally included in a controller in order to provide remember me behavior. Useful when signing in is done through a callback, like in OmniAuth.
Class Method Summary collapse
-
.cookie_values ⇒ Object
Return default cookie values retrieved from session options.
Instance Method Summary collapse
- #forget_cookie_values(resource) ⇒ Object protected
-
#forget_me(resource) ⇒ Object
Forgets the given resource by deleting a cookie.
- #remember_cookie_values(resource) ⇒ Object protected
- #remember_key(resource, scope) ⇒ Object protected
-
#remember_me(resource) ⇒ Object
Remembers the given resource by setting up a cookie.
Class Method Details
.cookie_values ⇒ Object
Return default cookie values retrieved from session options.
8 9 10 |
# File 'lib/devise/controllers/rememberable.rb', line 8 def self. Rails.configuration..slice(:path, :domain, :secure) end |
Instance Method Details
#forget_cookie_values(resource) ⇒ Object (protected)
29 30 31 |
# File 'lib/devise/controllers/rememberable.rb', line 29 def (resource) Devise::Controllers::Rememberable..merge!(resource.) end |
#forget_me(resource) ⇒ Object
Forgets the given resource by deleting a cookie
21 22 23 24 25 |
# File 'lib/devise/controllers/rememberable.rb', line 21 def forget_me(resource) scope = Devise::Mapping.find_scope!(resource) resource.forget_me! .delete(remember_key(resource, scope), (resource)) end |
#remember_cookie_values(resource) ⇒ Object (protected)
33 34 35 36 37 38 39 40 |
# File 'lib/devise/controllers/rememberable.rb', line 33 def (resource) = { httponly: true } .merge!((resource)) .merge!( value: resource.class.(resource), expires: resource.remember_expires_at ) end |
#remember_key(resource, scope) ⇒ Object (protected)
42 43 44 |
# File 'lib/devise/controllers/rememberable.rb', line 42 def remember_key(resource, scope) resource..fetch(:key, "remember_#{scope}_token") end |
#remember_me(resource) ⇒ Object
Remembers the given resource by setting up a cookie
13 14 15 16 17 18 |
# File 'lib/devise/controllers/rememberable.rb', line 13 def remember_me(resource) return if env["devise.skip_storage"] scope = Devise::Mapping.find_scope!(resource) resource.remember_me!(resource.extend_remember_period) .signed[remember_key(resource, scope)] = (resource) end |