In Devise , I'm signing in my user like this:
sign_in_and_redirect(:user, user)
In the default sign in page, there's a checkbox that the user can select so that they don't have to sign in again when they return to the site. But when you do the sign in with the sign_in_and_redirect(:user, user)
line, I can't work out how to set that parameter to yes. Does anyone know how? Thanks for reading.
Did some testing. Presenting the findings for others.
The simplest solution, assuming the user object has the rememberable module defined on the devise
declarable, is to set remember_me to true on the user before sign in and redirect:
@user.remember_me = true
sign_in_and_redirect(@user, :event => :authentication)
current_user.remember_me!
https://github.com/plataformatec/devise/blob/master/lib/devise/models/rememberable.rb#L54
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.