From 9899f055605babc0b84bbff791f9ad4268e293f0 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 13 Feb 2022 19:20:20 +0100 Subject: [PATCH] Add info flash translation for used recovery key --- app/controllers/user/sessions_controller.rb | 2 +- config/locales/controllers.en.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/user/sessions_controller.rb b/app/controllers/user/sessions_controller.rb index 361c6fb3..8829e017 100644 --- a/app/controllers/user/sessions_controller.rb +++ b/app/controllers/user/sessions_controller.rb @@ -21,7 +21,7 @@ class User::SessionsController < Devise::SessionsController if params[:user][:otp_attempt].length == 8 found = TotpRecoveryCode.where(user_id: resource.id, code: params[:user][:otp_attempt].downcase).delete_all if found == 1 - flash[:info] = "You have #{TotpRecoveryCode.where(user_id: resource.id).count} recovery codes remaining." + flash[:info] = t(".info", count: TotpRecoveryCode.where(user_id: resource.id).count) continue_sign_in(resource, resource_name) else flash[:error] = t(".error") diff --git a/config/locales/controllers.en.yml b/config/locales/controllers.en.yml index f466a568..53c7ece0 100644 --- a/config/locales/controllers.en.yml +++ b/config/locales/controllers.en.yml @@ -45,4 +45,5 @@ en: error: "Theme saving failed. %{errors}" sessions: create: + info: "You have %{count} recovery codes remaining." error: :errors.invalid_otp