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