From 787a82c88bfe1337a57e8fad8cd9cbc028639aa1 Mon Sep 17 00:00:00 2001 From: Carl Chenet Date: Wed, 17 May 2017 18:13:24 +0200 Subject: [PATCH] i18n of 2FA process --- app/controllers/settings_controller.rb | 22 ++++++++--------- app/views/settings/index.html.erb | 2 +- app/views/settings/twofa.html.erb | 14 +++++------ app/views/settings/twofa_enroll.html.erb | 12 +++------ app/views/settings/twofa_verify.html.erb | 5 ++-- config/locales/en.yml | 27 +++++++++++++++++++++ config/locales/fr.yml | 31 ++++++++++++++++++++++-- 7 files changed, 79 insertions(+), 34 deletions(-) diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index c7726c7..95c37e9 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -76,7 +76,7 @@ class SettingsController < ApplicationController end def twofa - @title = "Two-Factor Authentication" + @title = t('.title') end def twofa_auth @@ -86,22 +86,22 @@ class SettingsController < ApplicationController if @user.has_2fa? @user.disable_2fa! - flash[:success] = "Two-Factor Authentication has been disabled." + flash[:success] = t('.2fahasbeendisabled') return redirect_to "/settings" else return redirect_to twofa_enroll_url end else - flash[:error] = "Your password was not correct." + flash[:error] = t('.2fapassnotcorrect') return redirect_to twofa_url end end def twofa_enroll - @title = "Two-Factor Authentication" + @title = t('.title') if (Time.now.to_i - session[:last_authed].to_i) > TOTP_SESSION_TIMEOUT - flash[:error] = "Your enrollment period timed out." + flash[:error] = t('.enrollmenttimeout') return redirect_to twofa_url end @@ -122,11 +122,11 @@ class SettingsController < ApplicationController end def twofa_verify - @title = "Two-Factor Authentication" + @title = t('.title') if ((Time.now.to_i - session[:last_authed].to_i) > TOTP_SESSION_TIMEOUT) || !session[:totp_secret] - flash[:error] = "Your enrollment period timed out." + flash[:error] = t('.enrollmenttimeout') return redirect_to twofa_url end end @@ -134,7 +134,7 @@ class SettingsController < ApplicationController def twofa_update if ((Time.now.to_i - session[:last_authed].to_i) > TOTP_SESSION_TIMEOUT) || !session[:totp_secret] - flash[:error] = "Your enrollment period timed out." + flash[:error] = t('.enrollmenttimeout') return redirect_to twofa_url end @@ -146,13 +146,11 @@ class SettingsController < ApplicationController session[:u] = @user.session_token - flash[:success] = "Two-Factor Authentication has been enabled on " << - "your account." + flash[:success] = t('.2fahasbeenenabled') session.delete(:totp_secret) return redirect_to "/settings" else - flash[:error] = "Your TOTP code was invalid, please verify the " << - "current code in your TOTP application." + flash[:error] = t('.totpinvalid') return redirect_to twofa_verify_url end end diff --git a/app/views/settings/index.html.erb b/app/views/settings/index.html.erb index e009387..c907ffd 100644 --- a/app/views/settings/index.html.erb +++ b/app/views/settings/index.html.erb @@ -71,7 +71,7 @@ <% if @edit_user.totp_secret.present? %> - <%= t('.enrolled2fa') %> + <%= t('.enabled2fa') %> (<%= t('.disable2fa') %>) <% else %> <%= t('.disabled2fa') %> (<%= t('.enroll2fa') %>) diff --git a/app/views/settings/twofa.html.erb b/app/views/settings/twofa.html.erb index 66fb958..f687429 100644 --- a/app/views/settings/twofa.html.erb +++ b/app/views/settings/twofa.html.erb @@ -1,6 +1,6 @@
<%= @title %> @@ -9,24 +9,22 @@ <%= form_for @user, :url => twofa_auth_url, :method => :post do |f| %>

<% if @user.has_2fa? %> - To turn off two-factor authentication for your account, enter your - current password: + <%= t('.turnoff') %> <% else %> - To begin the two-factor authentication enrollment for your account, - enter your current password: + <%= t('.turnon') %> <% end %>

- <%= f.label :password, "Current Password:", :class => "required" %> + <%= f.label :password, t('.currentpassword'), :class => "required" %> <%= f.password_field :password, :size => 40, :autocomplete => "off" %>

<% if @user.has_2fa? %> - <%= submit_tag "Disable Two-Factor Authentication" %> + <%= submit_tag t('.disable2fa') %> <% else %> - <%= submit_tag "Continue" %> + <%= submit_tag t('.continue') %> <% end %> <% end %>

diff --git a/app/views/settings/twofa_enroll.html.erb b/app/views/settings/twofa_enroll.html.erb index b505190..2a49355 100644 --- a/app/views/settings/twofa_enroll.html.erb +++ b/app/views/settings/twofa_enroll.html.erb @@ -1,25 +1,21 @@
<%= @title %>

- Scan the QR code below or click on it to open in your TOTP application of choice: + <%= raw(t('.scanqrcode')) %>

<%= raw @qr_svg %>

- Once you have finished registering with your TOTP application, proceed to - the next screen to verify your current TOTP code and actually enable - Two-Factor Authentication on your account. + <%= t('.registring') %>

- <%= button_to "Verify and Enable", twofa_verify_url, :method => :get %> + <%= button_to t('.verifyenable'), twofa_verify_url, :method => :get %>

diff --git a/app/views/settings/twofa_verify.html.erb b/app/views/settings/twofa_verify.html.erb index db6ae10..4e45f17 100644 --- a/app/views/settings/twofa_verify.html.erb +++ b/app/views/settings/twofa_verify.html.erb @@ -8,8 +8,7 @@ <%= form_tag twofa_update_url do %>

- To enable Two-Factor Authentication on your account using your new TOTP - secret, enter the six-digit code from your TOTP application: + <%= t('.enablecode') %>

@@ -19,6 +18,6 @@

- <%= submit_tag "Verify and Enable" %> + <%= submit_tag t('.verifyenable') %> <% end %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index d5862ee..91c0e32 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -292,6 +292,33 @@ en: pushovernorandomtokenurl: "No random token present in URL" accountsetuppushover: "Your account is now setup for Pushover notifications." accountnolongersetuppushover: "Your account is no longer setup for Pushover notifications." + twofa: + title: "Two-Factor Authentication" + backtosettings: "Back to Settings" + disable2fa: "Disable Two-Factor Authentication" + continue: "Continue" + currentpassword: "Current Password:" + turnoff: "To turn off two-factor authentication for your account, enter your current password:" + turnon: "To begin the two-factor authentication enrollment for your account, enter your current password:" + twofa_auth: + 2fahasbeendisabled: "Two-Factor Authentication has been disabled on your account." + 2fapassnotcorrect: "Your password was not correct." + twofa_enroll: + title: "Two-Factor Authentication" + backtosettings: "Back to Settings" + enrollmenttimeout: "Your enrollment period timed out." + scanqrcode: "Scan the QR code below or click on it to open in your TOTP application of choice:" + registring: "Once you have finished registering with your TOTP application, proceed to the next screen to verify your current TOTP code and actually enable Two-Factor Authentication on your account." + verifyenable: "Verify and Enable" + twofa_update: + enrollmenttimeout: "Your enrollment period timed out." + 2fahasbeenenabled: "Two-Factor Authentication has been enabled on your account." + totpinvalid: "Your TOTP code was invalid, please verify the current code in your TOTP application." + twofa_verify: + title: "Two-Factor Authentication" + enrollmenttimeout: "Your enrollment period timed out." + enablecode: "To enable Two-Factor Authentication on your account using your new TOTP secret, enter the six-digit code from your TOTP application:" + verifyenable: "Verify and Enable" update: updatesettingsflash: "Successfully updated settings." stories: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index f2ba831..f755aac 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -293,8 +293,8 @@ fr: twofactorauth: "Authentification à deux facteurs :" disable2fa: "Désactiver" enroll2fa: "Activer" - disabled2fa: "Désactivé" - enabled2fa: "Activé" + disabled2fa: "Désactivée" + enabled2fa: "Activée" pushover: pushovernotconfigured: "Ce site n'est pas configuré pour le Pushover" pushover_callback: @@ -302,6 +302,33 @@ fr: pushovernorandomtokenurl: "Pas de jeton alétoire présent dans l'url" accountsetuppushover: "Votre compte est maintenant configuré pour les notifications Pushover." accountnolongersetuppushover: "Votre compte n'est plus configuré pour les notifications Pushover." + twofa: + title: "Authentification à deux facteurs" + backtosettings: "Retour aux paramètres" + disable2fa: "Désactiver l'authentification à deux facteurs" + continue: "Continuer" + currentpassword: "Mot de passe actuel :" + turnoff: "Pour désactiver l'authentification à deux facteurs, entrez votre mot de passe actuel :" + turnon: "Pour activer l'authentification à deux facteurs pour votre compte, entrez votre mot de passe actuel :" + twofa_auth: + 2fahasbeendisabled: "L'authentification à deux facteurs a été désactivée sur votre compte" + 2fapassnotcorrect: "Mot de passe incorrect" + twofa_enroll: + title: "Authentification à deux facteurs" + backtosettings: "Retour aux paramètres" + enrollmenttimeout: "Le délai d'attente est dépassé" + scanqrcode: "Scannez le QR code ci-dessous ou cliquez dessus pour l'ouvrir dans l'application TOTP de votre choix :" + registring: "Une fois le processus d'enregistrement de vos applications TOTP achevé, passez à l'écran suivant pour vérifier et activer l'authentification à deux facteurs pour votre compte." + verifyenable: "Vérifier et Activer" + twofa_update: + enrollmenttimeout: "Le délai d'attente est dépassé" + 2fahasbeenenabled: "L'authentification à deux facteurs a été activée sur votre compte" + totpinvalid: "Votre code TOTP est invalide, merci de vérifier le code actuellement affiché par votre application TOTP" + twofa_verify: + title: "Authentification à deux facteurs" + enrollmenttimeout: "Le délai d'attente est dépassé" + enablecode: "Afin d'activer l'authentification à deux facteurs pour votre compte en utilisant votre nouveau secret TOTP, entrez le code à 6 chiffres de votre application :" + verifyenable: "Vérifier et Activer" update: updatesettingsflash: "Paramètres mis à jour avec succès." stories: