mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
Merge pull request #3561 from aignatov-bio/ai-sci-6103-fix-2fa-redirecting
Fix 2fa redirecting [SCI-6103]
This commit is contained in:
commit
79074114f4
2 changed files with 5 additions and 2 deletions
|
@ -23,9 +23,10 @@ class Users::SessionsController < Devise::SessionsController
|
|||
def create
|
||||
super do |user|
|
||||
if redirect_to_two_factor_auth?(user)
|
||||
initial_page = stored_location_for(:user)
|
||||
sign_out
|
||||
session[:otp_user_id] = user.id
|
||||
store_location_for(:user, request.original_fullpath) if request.get?
|
||||
store_location_for(:user, initial_page)
|
||||
redirect_to users_two_factor_auth_path
|
||||
return
|
||||
end
|
||||
|
@ -40,6 +41,7 @@ class Users::SessionsController < Devise::SessionsController
|
|||
end
|
||||
|
||||
def two_factor_auth
|
||||
@initial_page = stored_location_for(:user)
|
||||
end
|
||||
|
||||
def after_sign_in
|
||||
|
@ -60,7 +62,7 @@ class Users::SessionsController < Devise::SessionsController
|
|||
sign_in(user)
|
||||
generate_templates_project
|
||||
flash[:notice] = t('devise.sessions.signed_in')
|
||||
redirect_to stored_location_for(:user) || root_path
|
||||
redirect_to params[:initial_page] || root_path
|
||||
else
|
||||
flash.now[:alert] = t('devise.sessions.2fa.error_message')
|
||||
render :two_factor_auth
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<div class="center-block center-block-narrow">
|
||||
<h1 class="log-in-title"><%= t "devise.sessions.2fa.title" %></h1>
|
||||
<%= form_with url: users_authenticate_with_two_factor_url, local: true do %>
|
||||
<%= hidden_field_tag :initial_page, @initial_page %>
|
||||
<p><%= t "devise.sessions.2fa.description" %></p>
|
||||
<p class="input-group sci-input-container">
|
||||
<%= label :otp, t("devise.sessions.2fa.field") %>
|
||||
|
|
Loading…
Reference in a new issue