From 7dca0c7128a77ebd0ea99b02222991f392dc006e Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Wed, 1 Dec 2021 21:28:33 +0000 Subject: [PATCH] Updating password keeps you signed in and redirects to show --- app/controllers/users_controller.rb | 7 +++++-- app/views/users/edit_password.html.erb | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 23731e2c0..3cacae301 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,9 +1,11 @@ class UsersController < ApplicationController + include Devise::Controllers::SignInOut before_action :authenticate_user! def update if current_user.update(user_params) - redirect_to(user_path) + bypass_sign_in current_user + redirect_to user_path(current_user) end end @@ -12,7 +14,8 @@ class UsersController < ApplicationController end def create - User.create!(user_params) + @user = User.create!(user_params) + redirect_to @user end def edit_password diff --git a/app/views/users/edit_password.html.erb b/app/views/users/edit_password.html.erb index f753a0223..b2b008f3b 100644 --- a/app/views/users/edit_password.html.erb +++ b/app/views/users/edit_password.html.erb @@ -5,7 +5,7 @@ ) %> <% end %> -<%= form_for(current_user, as: :user, url: password_path(:user), html: { method: :patch }) do |f| %> +<%= form_for(current_user, as: :user, html: { method: :patch }) do |f| %>

Change your password