Commit ae8f73f5 authored by o@immerda.ch's avatar o@immerda.ch
Browse files

add new option to send recovery code by email

parent 1bcf89e9
......@@ -172,13 +172,14 @@ module ApiBackend
post(['invites', 'generate'], {"number" => num, "expire" => expire, "domains" => domains})
end
def self.create_new_mailbox(email, pw, mail_crypt_enabled, invite, recovery_email, keep_recovery_token)
def self.create_new_mailbox(email, pw, mail_crypt_enabled, invite, recovery_email, recovery_token)
post(['users', 'create_new_mailbox'], {"email" => email,
"password" => pw,
"mail_crypt_enabled" => mail_crypt_enabled,
"invite" => invite,
"recovery_email" => recovery_email,
"keep_recovery_token" => keep_recovery_token,
"keep_recovery_token" => recovery_token == 'yes',
"email_recovery_token" => recovery_token == 'email',
"language" => I18n.locale,
})
end
......
......@@ -46,6 +46,11 @@ class SignupController < ApplicationController
return
end
if @keep_recovery_token == 'email' && !@recovery_email.present?
flash[:notice] = :missing_recovery_email
return
end
if @enable_mail_crypt && !@keep_recovery_token
flash[:notice] = :decide_recovery_token
return
......@@ -54,8 +59,8 @@ class SignupController < ApplicationController
begin
res = ApiBackend::create_new_mailbox(
full_email, @new_pw, @enable_mail_crypt, @token,
@recovery_email, @keep_recovery_token == 'yes')
if @keep_recovery_token != 'yes'
@recovery_email, @keep_recovery_token)
if @keep_recovery_token == 'show'
@mail_crypt_recovery_token = res['mail_crypt_recovery_token']
begin
@qr = RQRCode::QRCode.new(@mail_crypt_recovery_token, :size => 12, :level => :h)
......
......@@ -41,7 +41,7 @@
<h4><a id="pw-help-toggle" href="#" ><%= t(:password_help) %></a></h4>
<div id="pw-help" style="display:none;">
<%= render "password_help_#{I18n.locale}" rescue render 'help_en' %>
<%= render "password_help_#{I18n.locale}" rescue render 'password_help_en' %>
<hr />
</div>
......@@ -50,8 +50,13 @@
<br />
<%= t :recovery_token_help %>
<br />
<input type="radio" id="keep_recovery_token_no" name="keep_recovery_token" value="no"
<%= if @keep_recovery_token == 'no' then 'checked="checked"' else '' end %>
<input type="radio" id="keep_recovery_token_yes" name="keep_recovery_token" value="email"
<%= if @keep_recovery_token == 'email' then 'checked="checked"' else '' end %>
/>
<%= t(:backup_recovery_token_email) %>
<br />
<input type="radio" id="keep_recovery_token_no" name="keep_recovery_token" value="show"
<%= if @keep_recovery_token == 'show' then 'checked="checked"' else '' end %>
/>
<%= t(:backup_recovery_token_delete) %>
<br />
......
......@@ -22,6 +22,7 @@ de:
recovery_token_hint: "Wir empfehlen dir einen Wiederherstellungscode zu generieren"
backup_recovery_token_email: "Sende mir den Wiederherstellungscode an meine Backup Email Adresse."
backup_recovery_token_keep: "Ich kann den Wiederherstellungscode jetzt gerade nicht aufbewahren und werde ihn später generieren."
backup_recovery_token_delete: "Ich kann den Wiederherstellungscode jetzt sicher aufbewahren."
......@@ -81,6 +82,7 @@ de:
num_tokens: 'Anzahl Einladungscodes'
new_account: "Neues Konto"
invalid_recovery_email: "Backup Email ist keine gültige Adresse"
missing_recovery_email: "Backup Email fehlt"
auth_fail: "Falsches Passwort"
app_password_duplicate: "Applikations Passwort mit diesem Namen besteht bereits"
back: "zurück"
......
......@@ -22,6 +22,7 @@ en:
recovery_token_hint: "We recommend you generate a recovery token"
backup_recovery_token_email: "Send me my recovery token to my recovery email address."
backup_recovery_token_delete: "I can safely store my token."
backup_recovery_token_keep: "I can't safely store the token right now. I will generate one later."
......@@ -81,6 +82,7 @@ en:
num_tokens: 'Number of tokens'
new_account: "New Account"
invalid_recovery_email: "Recovery email is not valid"
missing_recovery_email: "Recovery email is missing"
auth_fail: "password wrong"
app_password_duplicate: "Application password with this name already exists"
back: "back"
......
......@@ -20,6 +20,7 @@ es:
recovery_token_hint: "Te recomendamos que generes un código de recuperación."
backup_recovery_token_email: "Envíame el código de recuperación a mi correo electrónico de respaldo."
backup_recovery_token_keep: "No puedo guardar el código de recuperación al momento. Lo voy a generar más tarde."
backup_recovery_token_delete: "Puedo ahorita guardar el código de recuperación de manera segura."
......@@ -77,6 +78,7 @@ es:
num_tokens: 'Cantidad de códigos'
new_account: "Nueva cuenta"
invalid_recovery_email: "El correo electrónico de respaldo no es una dirección válida"
missing_recovery_email: "Necessito un correo electrónico de respaldo"
auth_fail: "Contraseña incorrecta"
app_password_duplicate: "La contraseña de aplicación con este nombre ya existe"
back: "regresar"
......
......@@ -20,6 +20,7 @@ fr:
recovery_token_hint: "Nous te conseillons de générer un code de récupération"
backup_recovery_token_email: "Envoie moi le code de manière sécurisée à mon email de récupération."
backup_recovery_token_keep: "Je ne peux pas stocker le code de manière sécurisée pour le moment. J'en générerai un plus tard."
backup_recovery_token_delete: "Je peux stocker mon code de manière sécurisée."
......@@ -77,6 +78,7 @@ fr:
num_tokens: 'Quantité de codes'
new_account: "Nouveau compte"
invalid_recovery_email: "L'email de récupération n'est pas une adresse valide"
missing_recovery_email: "L'email de récupération manque"
auth_fail: "mot de passe faux"
app_password_duplicate: "Un mot de passe existe déjà pour ce nom d'application"
back: "retour"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment