Jeff
unread,Nov 13, 2009, 12:32:32 PM11/13/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Devise
I noticed that if I click "Remember me" when logging in, devise does
not set the remember_token cookie.
Warden::Manager.after_authentication do |record, auth, options|
scope = options[:scope]
remember_me = auth.params[scope].try(:fetch, :remember_me, nil)
if Devise::TRUE_VALUES.include?(remember_me) && record.respond_to?
(:remember_me!)
record.remember_me!
auth.cookies['remember_token'] = {
:value => record.class.serialize_into_cookie(record),
:expires => record.remember_expires_at
}
end
end
From the looks of things, you're assigning a new cookie to the
Request, which is then forgotten about at the end of the request (i.e.
no Set-Cookie header is set).
To fix it, it seems adding the following will work:
auth.env['action_controller.rescue.response'].set_cookie
('remember_token', auth.cookies['remember_token'].merge(:path => '/'))
Now this probably isn't the "right" solution, but it does tell the
response object about the new cookie, which then properly sets the Set-
Cookie response header.
Am I missing something here? Does the Rememberable module work for
anyone else?