Fix not working I18n on 2FA and Sign in token page (#14087)

This commit is contained in:
fuyu 2020-06-20 20:30:13 +09:00 committed by GitHub
parent ac8a788370
commit a279acc730
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 8 deletions

View file

@ -7,8 +7,6 @@ module Localized
around_action :set_locale around_action :set_locale
end end
private
def set_locale def set_locale
locale = current_user.locale if respond_to?(:user_signed_in?) && user_signed_in? locale = current_user.locale if respond_to?(:user_signed_in?) && user_signed_in?
locale ||= session[:locale] ||= default_locale locale ||= session[:locale] ||= default_locale
@ -19,6 +17,8 @@ module Localized
end end
end end
private
def default_locale def default_locale
if ENV['DEFAULT_LOCALE'].present? if ENV['DEFAULT_LOCALE'].present?
I18n.default_locale I18n.default_locale

View file

@ -42,8 +42,10 @@ module SignInTokenAuthenticationConcern
UserMailer.sign_in_token(user, request.remote_ip, request.user_agent, Time.now.utc.to_s).deliver_later! UserMailer.sign_in_token(user, request.remote_ip, request.user_agent, Time.now.utc.to_s).deliver_later!
end end
session[:attempt_user_id] = user.id set_locale do
@body_classes = 'lighter' session[:attempt_user_id] = user.id
render :sign_in_token @body_classes = 'lighter'
render :sign_in_token
end
end end
end end

View file

@ -40,8 +40,10 @@ module TwoFactorAuthenticationConcern
end end
def prompt_for_two_factor(user) def prompt_for_two_factor(user)
session[:attempt_user_id] = user.id set_locale do
@body_classes = 'lighter' session[:attempt_user_id] = user.id
render :two_factor @body_classes = 'lighter'
render :two_factor
end
end end
end end