diff --git a/app/controllers/user/sessions_controller.rb b/app/controllers/user/sessions_controller.rb index 58a18d94..a6fea348 100644 --- a/app/controllers/user/sessions_controller.rb +++ b/app/controllers/user/sessions_controller.rb @@ -22,7 +22,7 @@ class User::SessionsController < Devise::SessionsController continue_sign_in(resource, resource_name) else sign_out(resource) - flash[:error] = "Invalid code provided" + flash[:error] = t('views.auth.2fa.errors.invalid_code') redirect_to new_user_session_url end end diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index f8b25bfb..3caed751 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -190,10 +190,10 @@ class UserController < ApplicationController current_user.otp_module = :enabled if current_user.authenticate_otp(req_params[:otp_validation]) - flash[:success] = 'Two factor authentication has been enabled for your account.' + flash[:success] = I18n.t('views.auth.2fa.setup.success') current_user.save! else - flash[:error] = 'The code you entered was invalid.' + flash[:error] = t('views.auth.2fa.errors.invalid_code') end redirect_to edit_user_security_path diff --git a/config/locales/en.yml b/config/locales/en.yml index 89d295f1..68a2c8bc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -452,3 +452,7 @@ en: 2fa: title: "Two-factor authentication" otp_field: "One-time password" + errors: + invalid_code: "" + setup: + success: "Two factor authentication has been enabled for your account."