Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I keep the user signed in after they update their password using Devise? [duplicate]

Whenever a user updates their password, it signs the user out and asks them to sign in again. This is my action

users_controller.rb
  def update
    @user = User.find(params[:id])
    if @user.update user_params
      sign_in @user, bypass: true # for some reason Devise signs the user out
      redirect_to @user

http://www.rubydoc.info/github/plataformatec/devise/Devise/Controllers/SignInOut#sign_in-instance_method

I tried sign_in @user, also, but that didn't work. I tried it without sign_in but that didn't work either. I saw this answer, but it doesn't help: Devise is logging out users after a password change. Updating the user without the password is working OK. (There is some code not shown.)

Devise 3.4.1.

like image 615
Chloe Avatar asked May 23 '15 21:05

Chloe


1 Answers

I had to add a 'scope`. This worked.

sign_in :user, @user, bypass: true # for some reason Devise signs the user out

See answer here: https://stackoverflow.com/a/11589286/148844

like image 196
Chloe Avatar answered Nov 14 '22 23:11

Chloe