From 069704cb78076629dfe6cccbfeb134ce451ad2d4 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Thu, 17 Dec 2020 19:32:15 +0100 Subject: [PATCH] Fix redirects after 2FA sign in [SCI-4973] --- app/controllers/users/sessions_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index 5da9aaab6..b35519a53 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -68,7 +68,6 @@ class Users::SessionsController < Devise::SessionsController flash[:system_notification_modal] = true end - def authenticate_with_two_factor user = User.find_by(id: session[:otp_user_id]) @@ -83,7 +82,7 @@ class Users::SessionsController < Devise::SessionsController sign_in(user) generate_demo_project flash[:notice] = t('devise.sessions.signed_in') - redirect_to root_path + redirect_to stored_location_for(:user) || root_path else flash.now[:alert] = t('devise.sessions.2fa.error_message') render :two_factor_auth @@ -126,6 +125,7 @@ class Users::SessionsController < Devise::SessionsController if user&.two_factor_auth_enabled? session[:otp_user_id] = user.id + store_location_for(:user, request.original_fullpath) if request.get? render :two_factor_auth end end