Module: Devise::Hooks::Rememberable

Defined in:
lib/devise/hooks/rememberable.rb

Overview

Overwrite success! in authentication strategies allowing users to be remembered. We choose to implement this as an strategy hook instead of a warden hook to allow a specific strategy (like token authenticatable or facebook authenticatable) to turn off remember_me? cookies.

Instance Method Summary collapse

Instance Method Details

#success!(resource) ⇒ Object

:nodoc:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/devise/hooks/rememberable.rb', line 8

def success!(resource)
  super

  if succeeded? && resource.respond_to?(:remember_me!) && remember_me?
    resource.remember_me!(extend_remember_period?)

    configuration = {
      :value => resource.class.serialize_into_cookie(resource),
      :expires => resource.remember_expires_at,
      :path => "/"
    }

    configuration[:domain] = resource.cookie_domain if resource.cookie_domain?
    cookies.signed["remember_#{scope}_token"] = configuration
  end
end