diff --git a/appinfo/routes.php b/appinfo/routes.php index 742a3e35d4a8f125336def744bb65d424736a1b5..e37b59fff784fa7c9182331e8aae052b7380b362 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -29,6 +29,9 @@ return [ ['name' => 'email_recovery_api#preflighted_cors', 'url' => '/api/{path}', 'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']], ['name' => 'email_recovery_api#show', 'url' => '/api/recovery-email/{id}', 'verb' => 'GET'], - ['name' => 'email_recovery_api#update', 'url' => '/api/recovery-email/{id}', 'verb' => 'PUT'] + ['name' => 'email_recovery_api#update', 'url' => '/api/recovery-email/{id}', 'verb' => 'PUT'], + ['name' => 'email_recovery#verify_recovery_email', 'url' => '/recovery-email/verify/{token}/{userId}', 'verb' => 'GET'], + ['name' => 'email_recovery#resend_recovery_email', 'url' => '/resend_recovery_email', 'verb' => 'POST'], + ] ]; diff --git a/l10n/de.js b/l10n/de.js index 8de0a5729f938ea053c5b8cbc6783bdb9b820f33..c23bf04f9e1b3e4c0df0bd33f8bc2b22c8c2a4eb 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -8,6 +8,22 @@ OC.L10N.register( "Recovery Email" : "Wiederherstellungs-E-Mail", "Change Recovery Email" : "Wiederherstellungs-E-Mail ändern", "Recovery Email " : "Wiederherstellungs-E-Mail ", - "Changes saved" : "Änderungen gespeichert" + "Changes saved" : "Änderungen gespeichert", + "Please check your inbox. An email has been sent to you for verification.": "Bitte überprüfen Sie Ihren Posteingang. Es wurde eine E-Mail zur Überprüfung an Sie gesendet.", + "Resend Verification Email": "Verifizierungs-E-Mail erneut senden", + "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail ist nicht verifiziert.", + "Recovery email is verified.": "Die Wiederherstellungs-E-Mail wird überprüft.", + "Hello %s": "Hallo %s", + "This is to inform you that the recovery email for your %s account has been successfully updated.": "Hiermit wird Ihnen mitgeteilt, dass die Wiederherstellungs-E-Mail für Ihr %s-Konto erfolgreich aktualisiert wurde.", + "To verify your new recovery email, please click on the following button.": "Um Ihre neue Wiederherstellungs-E-Mail zu überprüfen, klicken Sie bitte auf die folgende Schaltfläche.", + "Verify recovery email": "Überprüfen der Wiederherstellungs-E-Mail", + "Please note that this link will be valid for the next 30 minutes.": "Bitte beachten Sie, dass dieser Link nur für die nächsten 30 Minuten gültig ist.", + "If you did not initiate this change, please contact our support team immediately.": "Wenn Sie diese Änderung nicht veranlasst haben, wenden Sie sich bitte umgehend an unser Support-Team.", + "Thank you for choosing %s.": "Danke, dass Sie sich für %s entschieden haben.", + "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben.", + "You verified recovery email successfully.": "Sie haben die Wiederherstellungs-E-Mail erfolgreich verifiziert.", + "Could not verify recovery email because the token is expired": "Wiederherstellungs-E-Mail konnte nicht verifiziert werden, da das Token abgelaufen ist", + "Could not verify recovery email because the token is invalid": "Wiederherstellungs-E-Mail konnte nicht verifiziert werden, da das Token ungültig ist", + "Unverified recovery email:": "Nicht verifizierte Wiederherstellungs-E-Mail:" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de.json b/l10n/de.json index 44b96899966b6fef1b91df9bc9b508a385f1183f..b05534e374b74fd93dab393be91396244aa76b1b 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -6,6 +6,22 @@ "Recovery Email" : "Wiederherstellungs-E-Mail", "Change Recovery Email" : "Wiederherstellungs-E-Mail ändern", "Recovery Email " : "Wiederherstellungs-E-Mail ", - "Changes saved" : "Änderungen gespeichert" + "Changes saved" : "Änderungen gespeichert", + "Please check your inbox. An email has been sent to you for verification.": "Bitte überprüfen Sie Ihren Posteingang. Es wurde eine E-Mail zur Überprüfung an Sie gesendet.", + "Resend Verification Email": "Verifizierungs-E-Mail erneut senden", + "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail ist nicht verifiziert.", + "Recovery email is verified.": "Die Wiederherstellungs-E-Mail wird überprüft.", + "Hello %s": "Hallo %s", + "This is to inform you that the recovery email for your %s account has been successfully updated.": "Hiermit wird Ihnen mitgeteilt, dass die Wiederherstellungs-E-Mail für Ihr %s-Konto erfolgreich aktualisiert wurde.", + "To verify your new recovery email, please click on the following button.": "Um Ihre neue Wiederherstellungs-E-Mail zu überprüfen, klicken Sie bitte auf die folgende Schaltfläche.", + "Verify recovery email": "Überprüfen der Wiederherstellungs-E-Mail", + "Please note that this link will be valid for the next 30 minutes.": "Bitte beachten Sie, dass dieser Link nur für die nächsten 30 Minuten gültig ist.", + "If you did not initiate this change, please contact our support team immediately.": "Wenn Sie diese Änderung nicht veranlasst haben, wenden Sie sich bitte umgehend an unser Support-Team.", + "Thank you for choosing %s.": "Danke, dass Sie sich für %s entschieden haben.", + "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben.", + "You verified recovery email successfully.": "Sie haben die Wiederherstellungs-E-Mail erfolgreich verifiziert.", + "Could not verify recovery email because the token is expired": "Wiederherstellungs-E-Mail konnte nicht verifiziert werden, da das Token abgelaufen ist", + "Could not verify recovery email because the token is invalid": "Wiederherstellungs-E-Mail konnte nicht verifiziert werden, da das Token ungültig ist", + "Unverified recovery email:": "Nicht verifizierte Wiederherstellungs-E-Mail:" },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/de_DE.js b/l10n/de_DE.js index 8de0a5729f938ea053c5b8cbc6783bdb9b820f33..7cab140bb7e15b6af6aac9fd881a63f4701d6b36 100644 --- a/l10n/de_DE.js +++ b/l10n/de_DE.js @@ -8,6 +8,22 @@ OC.L10N.register( "Recovery Email" : "Wiederherstellungs-E-Mail", "Change Recovery Email" : "Wiederherstellungs-E-Mail ändern", "Recovery Email " : "Wiederherstellungs-E-Mail ", - "Changes saved" : "Änderungen gespeichert" + "Changes saved" : "Änderungen gespeichert", + "Please check your inbox. An email has been sent to you for verification.": "Bitte überprüfen Sie Ihren Posteingang. Es wurde eine E-Mail zur Überprüfung an Sie gesendet.", + "Resend Verification Email": "Verifizierungs-E-Mail erneut senden", + "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail ist nicht verifiziert.", + "Recovery email is verified.": "Die Wiederherstellungs-E-Mail wird überprüft.", + "Hello %s": "Hallo %s", + "This is to inform you that the recovery email for your %s account has been successfully updated.": "Hiermit wird Ihnen mitgeteilt, dass die Wiederherstellungs-E-Mail für Ihr %s-Konto erfolgreich aktualisiert wurde.", + "To verify your new recovery email, please click on the following button.": "Um Ihre neue Wiederherstellungs-E-Mail zu überprüfen, klicken Sie bitte auf die folgende Schaltfläche.", + "Verify recovery email": "Überprüfen der Wiederherstellungs-E-Mail", + "Please note that this link will be valid for the next 30 minutes.": "Bitte beachten Sie, dass dieser Link nur für die nächsten 30 Minuten gültig ist.", + "If you did not initiate this change, please contact our support team immediately.": "Wenn Sie diese Änderung nicht veranlasst haben, wenden Sie sich bitte umgehend an unser Support-Team.", + "Thank you for choosing %s.": "Danke, dass Sie sich für %s entschieden haben.", + "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben.", + "You verified recovery email successfully.": "Sie haben die Wiederherstellungs-E-Mail erfolgreich verifiziert.", + "Could not verify recovery email because the token is expired": "Wiederherstellungs-E-Mail konnte nicht verifiziert werden, da das Token abgelaufen ist", + "Could not verify recovery email because the token is invalid": "Wiederherstellungs-E-Mail konnte nicht verifiziert werden, da das Token ungültig ist", + "Unverified recovery email:": "Nicht verifizierte Wiederherstellungs-E-Mail:" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de_DE.json b/l10n/de_DE.json index 44b96899966b6fef1b91df9bc9b508a385f1183f..b05534e374b74fd93dab393be91396244aa76b1b 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -6,6 +6,22 @@ "Recovery Email" : "Wiederherstellungs-E-Mail", "Change Recovery Email" : "Wiederherstellungs-E-Mail ändern", "Recovery Email " : "Wiederherstellungs-E-Mail ", - "Changes saved" : "Änderungen gespeichert" + "Changes saved" : "Änderungen gespeichert", + "Please check your inbox. An email has been sent to you for verification.": "Bitte überprüfen Sie Ihren Posteingang. Es wurde eine E-Mail zur Überprüfung an Sie gesendet.", + "Resend Verification Email": "Verifizierungs-E-Mail erneut senden", + "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail ist nicht verifiziert.", + "Recovery email is verified.": "Die Wiederherstellungs-E-Mail wird überprüft.", + "Hello %s": "Hallo %s", + "This is to inform you that the recovery email for your %s account has been successfully updated.": "Hiermit wird Ihnen mitgeteilt, dass die Wiederherstellungs-E-Mail für Ihr %s-Konto erfolgreich aktualisiert wurde.", + "To verify your new recovery email, please click on the following button.": "Um Ihre neue Wiederherstellungs-E-Mail zu überprüfen, klicken Sie bitte auf die folgende Schaltfläche.", + "Verify recovery email": "Überprüfen der Wiederherstellungs-E-Mail", + "Please note that this link will be valid for the next 30 minutes.": "Bitte beachten Sie, dass dieser Link nur für die nächsten 30 Minuten gültig ist.", + "If you did not initiate this change, please contact our support team immediately.": "Wenn Sie diese Änderung nicht veranlasst haben, wenden Sie sich bitte umgehend an unser Support-Team.", + "Thank you for choosing %s.": "Danke, dass Sie sich für %s entschieden haben.", + "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben.", + "You verified recovery email successfully.": "Sie haben die Wiederherstellungs-E-Mail erfolgreich verifiziert.", + "Could not verify recovery email because the token is expired": "Wiederherstellungs-E-Mail konnte nicht verifiziert werden, da das Token abgelaufen ist", + "Could not verify recovery email because the token is invalid": "Wiederherstellungs-E-Mail konnte nicht verifiziert werden, da das Token ungültig ist", + "Unverified recovery email:": "Nicht verifizierte Wiederherstellungs-E-Mail:" },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/en.js b/l10n/en.js index 221150a20d39ed82a70acecd0b5b40221b5c773a..c7438644822be0d6f42802dc8afc3403d90dd924 100644 --- a/l10n/en.js +++ b/l10n/en.js @@ -5,6 +5,23 @@ OC.L10N.register( "Changes saved": "Changes saved", "Error! User email address cannot be saved as recovery email address!": "Error! User email address cannot be saved as recovery email address!", "Change Recovery Email": "Change Recovery Email", - "Invalid Recovery Email!": "Invalid Recovery Email!" + "Invalid Recovery Email": "Invalid Recovery Email", + "Please check your inbox. An email has been sent to you for verification.": "Please check your inbox. An email has been sent to you for verification.", + "Resend Verification Email": "Resend Verification Email", + "Recovery email is not verified.": "Recovery email is not verified.", + "Recovery email is verified.": "Recovery email is verified.", + "Recovery Email Update in Your %s Account": "Recovery Email Update in Your %s Account", + "Hello %s": "Hello %s", + "This is to inform you that the recovery email for your %s account has been successfully updated.": "This is to inform you that the recovery email for your %s account has been successfully updated.", + "To verify your new recovery email, please click on the following button.": "To verify your new recovery email, please click on the following button.", + "Verify recovery email": "Verify recovery email", + "Please note that this link will be valid for the next 30 minutes.": "Please note that this link will be valid for the next 30 minutes.", + "If you did not initiate this change, please contact our support team immediately.": "If you did not initiate this change, please contact our support team immediately.", + "Thank you for choosing %s.": "Thank you for choosing %s.", + "Recovery email address is already taken.": "Recovery email address is already taken.", + "You verified recovery email successfully.": "You verified recovery email successfully.", + "Could not verify recovery email because the token is expired": "Could not verify recovery email because the token is expired", + "Could not verify recovery email because the token is invalid": "Could not verify recovery email because the token is invalid", + "Unverified recovery email:": "Unverified recovery email:" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/en.json b/l10n/en.json index eb9d64890f79ec0721a25a58a4b8a760f9ec03fb..1193fd86f475224988c4652c678932d2fe69b4ca 100644 --- a/l10n/en.json +++ b/l10n/en.json @@ -4,8 +4,24 @@ "Changes saved": "Changes saved", "Error! User email address cannot be saved as recovery email address!": "Error! User email address cannot be saved as recovery email address!", "Change Recovery Email": "Change Recovery Email", - "Invalid Recovery Email!": "Invalid Recovery Email!", - "Error setting recovery email": "Error setting recovery mail" + "Invalid Recovery Email": "Invalid Recovery Email", + "Error setting recovery email": "Error setting recovery mail", + "Please check your inbox. An email has been sent to you for verification.": "Please check your inbox. An email has been sent to you for verification.", + "Resend Verification Email": "Resend Verification Email", + "Recovery email is not verified.": "Recovery email is not verified.", + "Recovery email is verified.": "Recovery email is verified.", + "Hello %s": "Hello %s", + "This is to inform you that the recovery email for your %s account has been successfully updated.": "This is to inform you that the recovery email for your %s account has been successfully updated.", + "To verify your new recovery email, please click on the following button.": "To verify your new recovery email, please click on the following button.", + "Verify recovery email": "Verify recovery email", + "Please note that this link will be valid for the next 30 minutes.": "Please note that this link will be valid for the next 30 minutes.", + "If you did not initiate this change, please contact our support team immediately.": "If you did not initiate this change, please contact our support team immediately.", + "Thank you for choosing %s.": "Thank you for choosing %s.", + "Recovery email address is already taken.": "Recovery email address is already taken.", + "You verified recovery email successfully.": "You verified recovery email successfully.", + "Could not verify recovery email because the token is expired": "Could not verify recovery email because the token is expired", + "Could not verify recovery email because the token is invalid": "Could not verify recovery email because the token is invalid", + "Unverified recovery email:": "Unverified recovery email:" }, "pluralForm": "nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/l10n/es.js b/l10n/es.js index ac209fc4c44f3855deb49a57a5ff5fd6f37372d9..9169737a8530bc65ac01c771d8c8a0ddb5de97bc 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -8,6 +8,22 @@ OC.L10N.register( "Recovery Email" : "Correo electrónico de recuperación", "Change Recovery Email" : "Cambiar correo electrónico de recuperación", "Recovery Email " : "Correo electrónico de recuperación ", - "Changes saved" : "Cambios guardados" + "Changes saved" : "Cambios guardados", + "Please check your inbox. An email has been sent to you for verification.": "Por favor, compruebe su bandeja de entrada. Se le ha enviado un correo electrónico para su verificación.", + "Resend Verification Email": "Reenviar correo de verificación", + "Recovery email is not verified.": "El correo electrónico de recuperación no está verificado.", + "Recovery email is verified.": "El correo electrónico de recuperación está verificado.", + "Hello %s": "Hola %s", + "This is to inform you that the recovery email for your %s account has been successfully updated.": "Esto es para informarle de que el correo electrónico de recuperación de su cuenta %s se ha actualizado correctamente.", + "To verify your new recovery email, please click on the following button.": "Para verificar su nuevo correo electrónico de recuperación, haga clic en el siguiente botón.", + "Verify recovery email": "Verificar el correo electrónico de recuperación", + "Please note that this link will be valid for the next 30 minutes.": "Tenga en cuenta que este enlace será válido durante los próximos 30 minutos.", + "If you did not initiate this change, please contact our support team immediately.": "Si no ha iniciado este cambio, póngase en contacto con nuestro equipo de asistencia inmediatamente.", + "Thank you for choosing %s.": "Gracias por elegir %s.", + "Recovery email address is already taken.": "La dirección de correo electrónico de recuperación ya está ocupada.", + "You verified recovery email successfully.": "Ha verificado correctamente el correo electrónico de recuperación.", + "Could not verify recovery email because the token is expired": "No se ha podido verificar el correo electrónico de recuperación porque el token ha caducado.", + "Could not verify recovery email because the token is invalid": "No se ha podido verificar el correo electrónico de recuperación porque el token no es válido", + "Unverified recovery email:": "Correo electrónico de recuperación no verificado:" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/es.json b/l10n/es.json index 2941d980e1ec0a987760fb719bc1c524ead67840..8d3aafbe2b34f2da5cf485bd7bf5f54368b66860 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -6,6 +6,22 @@ "Recovery Email" : "Correo electrónico de recuperación", "Change Recovery Email" : "Cambiar correo electrónico de recuperación", "Recovery Email " : "Correo electrónico de recuperación ", - "Changes saved" : "Cambios guardados" + "Changes saved" : "Cambios guardados", + "Please check your inbox. An email has been sent to you for verification.": "Por favor, compruebe su bandeja de entrada. Se le ha enviado un correo electrónico para su verificación.", + "Resend Verification Email": "Reenviar correo de verificación", + "Recovery email is not verified.": "El correo electrónico de recuperación no está verificado.", + "Recovery email is verified.": "El correo electrónico de recuperación está verificado.", + "Hello %s": "Hola %s", + "This is to inform you that the recovery email for your %s account has been successfully updated.": "Esto es para informarle de que el correo electrónico de recuperación de su cuenta %s se ha actualizado correctamente.", + "To verify your new recovery email, please click on the following button.": "Para verificar su nuevo correo electrónico de recuperación, haga clic en el siguiente botón.", + "Verify recovery email": "Verificar el correo electrónico de recuperación", + "Please note that this link will be valid for the next 30 minutes.": "Tenga en cuenta que este enlace será válido durante los próximos 30 minutos.", + "If you did not initiate this change, please contact our support team immediately.": "Si no ha iniciado este cambio, póngase en contacto con nuestro equipo de asistencia inmediatamente.", + "Thank you for choosing %s.": "Gracias por elegir %s.", + "Recovery email address is already taken.": "La dirección de correo electrónico de recuperación ya está ocupada.", + "You verified recovery email successfully.": "Ha verificado correctamente el correo electrónico de recuperación.", + "Could not verify recovery email because the token is expired": "No se ha podido verificar el correo electrónico de recuperación porque el token ha caducado.", + "Could not verify recovery email because the token is invalid": "No se ha podido verificar el correo electrónico de recuperación porque el token no es válido", + "Unverified recovery email:": "Correo electrónico de recuperación no verificado:" },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/fr.js b/l10n/fr.js index 4e31d62e919c84cc4ef392de1e13abfbda763d29..d86d48de2eb271566cd63ea231db0e8617805416 100644 --- a/l10n/fr.js +++ b/l10n/fr.js @@ -8,6 +8,22 @@ OC.L10N.register( "Recovery Email" : "Courriel de récupération", "Change Recovery Email" : "Modifier le courriel de récupération", "Recovery Email " : "Courriel de récupération ", - "Changes saved" : "Changements enregistrés" + "Changes saved" : "Changements enregistrés", + "Please check your inbox. An email has been sent to you for verification.": "Veuillez vérifier votre boîte de réception. Un courriel vous a été envoyé pour vérification.", + "Resend Verification Email": "Renvoyer l'e-mail de vérification", + "Recovery email is not verified.": "L'e-mail de récupération n'est pas vérifié.", + "Recovery email is verified.": "L'email de récupération est vérifié.", + "Hello %s": "Bonjour %s", + "This is to inform you that the recovery email for your %s account has been successfully updated.": "Nous vous informons que l'e-mail de récupération de votre compte %s a été mis à jour avec succès.", + "To verify your new recovery email, please click on the following button.": "Pour vérifier votre nouvel email de récupération, veuillez cliquer sur le bouton suivant.", + "Verify recovery email": "Vérifier l'e-mail de récupération", + "Please note that this link will be valid for the next 30 minutes.": "Veuillez noter que ce lien est valable pour les 30 prochaines minutes.", + "If you did not initiate this change, please contact our support team immediately.": "Si vous n'êtes pas à l'origine de ce changement, veuillez contacter immédiatement notre équipe d'assistance.", + "Thank you for choosing %s.": "Merci d'avoir choisi %s.", + "Recovery email address is already taken.": "L'adresse électronique de récupération est déjà prise.", + "You verified recovery email successfully.": "Vous avez vérifié l'email de récupération avec succès.", + "Could not verify recovery email because the token is expired": "Impossible de vérifier l'e-mail de récupération car le jeton a expiré.", + "Could not verify recovery email because the token is invalid": "Impossible de vérifier l'e-mail de récupération car le jeton n'est pas valide.", + "Unverified recovery email:": "Courriel de récupération non vérifié :" }, "nplurals=2; plural=n > 1;"); diff --git a/l10n/fr.json b/l10n/fr.json index c422d423a95d837ac92750fb44ba8f12535c7b2c..40f2a22b84baa4a7bb3c3825401979613847f44c 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -6,6 +6,22 @@ "Recovery Email" : "Courriel de récupération", "Change Recovery Email" : "Modifier le courriel de récupération", "Recovery Email " : "Courriel de récupération ", - "Changes saved" : "Changements enregistrés" + "Changes saved" : "Changements enregistrés", + "Please check your inbox. An email has been sent to you for verification.": "Veuillez vérifier votre boîte de réception. Un courriel vous a été envoyé pour vérification.", + "Resend Verification Email": "Renvoyer l'e-mail de vérification", + "Recovery email is not verified.": "L'e-mail de récupération n'est pas vérifié.", + "Recovery email is verified.": "L'email de récupération est vérifié.", + "Hello %s": "Bonjour %s", + "This is to inform you that the recovery email for your %s account has been successfully updated.": "Nous vous informons que l'e-mail de récupération de votre compte %s a été mis à jour avec succès.", + "To verify your new recovery email, please click on the following button.": "Pour vérifier votre nouvel email de récupération, veuillez cliquer sur le bouton suivant.", + "Verify recovery email": "Vérifier l'e-mail de récupération", + "Please note that this link will be valid for the next 30 minutes.": "Veuillez noter que ce lien est valable pour les 30 prochaines minutes.", + "If you did not initiate this change, please contact our support team immediately.": "Si vous n'êtes pas à l'origine de ce changement, veuillez contacter immédiatement notre équipe d'assistance.", + "Thank you for choosing %s.": "Merci d'avoir choisi %s.", + "Recovery email address is already taken.": "L'adresse électronique de récupération est déjà prise.", + "You verified recovery email successfully.": "Vous avez vérifié l'email de récupération avec succès.", + "Could not verify recovery email because the token is expired": "Impossible de vérifier l'e-mail de récupération car le jeton a expiré.", + "Could not verify recovery email because the token is invalid": "Impossible de vérifier l'e-mail de récupération car le jeton n'est pas valide.", + "Unverified recovery email:": "Courriel de récupération non vérifié :" },"pluralForm" :"nplurals=2; plural=n > 1;" } \ No newline at end of file diff --git a/l10n/it.js b/l10n/it.js index 02879b77641a3cb2ec81456c1e3b887222b91270..48d32cd16240811d0cabfaa5d4ec0d09b4010e56 100644 --- a/l10n/it.js +++ b/l10n/it.js @@ -8,6 +8,22 @@ OC.L10N.register( "Recovery Email" : "Recupero e-mail", "Change Recovery Email" : "Modifica dell'e-mail di recupero", "Recovery Email " : "Recupero e-mail ", - "Changes saved" : "Modifiche salvate" + "Changes saved" : "Modifiche salvate", + "Please check your inbox. An email has been sent to you for verification.": "Controllare la posta in arrivo. Le è stata inviata un'e-mail di verifica.", + "Resend Verification Email": "Reinvio dell'e-mail di verifica", + "Recovery email is not verified.": "L'e-mail di recupero non è verificata.", + "Recovery email is verified.": "L'e-mail di recupero è verificata.", + "Hello %s": "Ciao %s", + "This is to inform you that the recovery email for your %s account has been successfully updated.": "Questo per informarvi che l'e-mail di recupero per il vostro account %s è stata aggiornata con successo.", + "To verify your new recovery email, please click on the following button.": "Per verificare la nuova e-mail di recupero, fare clic sul seguente pulsante.", + "Verify recovery email": "Verifica dell'e-mail di recupero", + "Please note that this link will be valid for the next 30 minutes.": "Si noti che questo link sarà valido per i prossimi 30 minuti.", + "If you did not initiate this change, please contact our support team immediately.": "Se non avete avviato questa modifica, contattate immediatamente il nostro team di assistenza.", + "Thank you for choosing %s.": "Grazie per aver scelto %s.", + "Recovery email address is already taken.": "L'indirizzo e-mail di recupero è già stato preso.", + "You verified recovery email successfully.": "L'e-mail di recupero è stata verificata con successo.", + "Could not verify recovery email because the token is expired": "Impossibile verificare l'email di recupero perché il token è scaduto", + "Could not verify recovery email because the token is invalid": "Impossibile verificare l'email di recupero perché il token non è valido", + "Unverified recovery email:": "Email di recupero non verificata:" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/it.json b/l10n/it.json index 2edf4b746d90817e88c6cec212c056a9e2a6d688..fb26f937796561bf5937ed42cfb5b0acf92f6186 100644 --- a/l10n/it.json +++ b/l10n/it.json @@ -6,6 +6,22 @@ "Recovery Email" : "Recupero e-mail", "Change Recovery Email" : "Modifica dell'e-mail di recupero", "Recovery Email " : "Recupero e-mail ", - "Changes saved" : "Modifiche salvate" + "Changes saved" : "Modifiche salvate", + "Please check your inbox. An email has been sent to you for verification.": "Controllare la posta in arrivo. Le è stata inviata un'e-mail di verifica.", + "Resend Verification Email": "Reinvio dell'e-mail di verifica", + "Recovery email is not verified.": "L'e-mail di recupero non è verificata.", + "Recovery email is verified.": "L'e-mail di recupero è verificata.", + "Hello %s": "Ciao %s", + "This is to inform you that the recovery email for your %s account has been successfully updated.": "Questo per informarvi che l'e-mail di recupero per il vostro account %s è stata aggiornata con successo.", + "To verify your new recovery email, please click on the following button.": "Per verificare la nuova e-mail di recupero, fare clic sul seguente pulsante.", + "Verify recovery email": "Verifica dell'e-mail di recupero", + "Please note that this link will be valid for the next 30 minutes.": "Si noti che questo link sarà valido per i prossimi 30 minuti.", + "If you did not initiate this change, please contact our support team immediately.": "Se non avete avviato questa modifica, contattate immediatamente il nostro team di assistenza.", + "Thank you for choosing %s.": "Grazie per aver scelto %s.", + "Recovery email address is already taken.": "L'indirizzo e-mail di recupero è già stato preso.", + "You verified recovery email successfully.": "L'e-mail di recupero è stata verificata con successo.", + "Could not verify recovery email because the token is expired": "Impossibile verificare l'email di recupero perché il token è scaduto", + "Could not verify recovery email because the token is invalid": "Impossibile verificare l'email di recupero perché il token non è valido", + "Unverified recovery email:": "Email di recupero non verificata:" },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 3c6a81eec293f3dd9cb813b909c899ae8c5a48fa..5296b1cd0fe704b0631bf18b8dd348f643897884 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -1,13 +1,48 @@ + * + * @author Florent VINCENT + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ namespace OCA\EmailRecovery\AppInfo; use OCP\AppFramework\App; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCA\EmailRecovery\Listeners\UserConfigChangedListener; +use OCP\User\Events\UserConfigChangedEvent; +use OCP\AppFramework\Bootstrap\IBootContext; + +class Application extends App implements IBootstrap { + public const APP_ID = 'email-recovery'; -class Application extends App { - public function __construct(array $urlParams = array()) { - $appName = 'email-recovery'; - parent::__construct($appName, $urlParams); + public function __construct(array $urlParams = []) { + parent::__construct(self::APP_ID, $urlParams); + } + + public function register(IRegistrationContext $context): void { + $context->registerEventListener(UserConfigChangedEvent::class, UserConfigChangedListener::class); + } + public function boot(IBootContext $context): void { } } diff --git a/lib/Controller/EmailRecoveryController.php b/lib/Controller/EmailRecoveryController.php index ce4f7a56c36a32cf40164be3bfbce2c0fe0dbc37..9fab9c73c593ca33647f80aa65c29abb5a44359c 100644 --- a/lib/Controller/EmailRecoveryController.php +++ b/lib/Controller/EmailRecoveryController.php @@ -30,25 +30,27 @@ use OCP\IConfig; use OCP\ILogger; use \OCP\IL10N; use OCP\IUserSession; -use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\JSONResponse; use OCA\EmailRecovery\Service\RecoveryEmailService; use OCA\EmailRecovery\Exception\InvalidRecoveryEmailException; use OCA\EmailRecovery\Exception\SameRecoveryEmailAsEmailException; +use OCA\EmailRecovery\Exception\RecoveryEmailAlreadyFoundException; +use OCP\IUserManager; +use OCP\Security\VerificationToken\IVerificationToken; +use OCP\Security\VerificationToken\InvalidTokenException; +use Exception; +use OCP\AppFramework\Http\TemplateResponse; +use OCP\Security\ICrypto; class EmailRecoveryController extends Controller { - /** @var IConfig */ - private $config; - - /** @var ILogger */ - private $logger; - - /** @var IL10N */ - private $l; - - private $userSession; - - private $recoveryEmailService; + private IConfig $config; + private ILogger $logger; + private IL10N $l; + private IUserSession $userSession; + private RecoveryEmailService $recoveryEmailService; + private IUserManager $userManager; + private IVerificationToken $verificationToken; + private ICrypto $crypto; public function __construct( string $appName, @@ -57,7 +59,10 @@ class EmailRecoveryController extends Controller { ILogger $logger, IL10N $l, IUserSession $userSession, - RecoveryEmailService $recoveryEmailService + RecoveryEmailService $recoveryEmailService, + IUserManager $userManager, + IVerificationToken $verificationToken, + ICrypto $crypto ) { parent::__construct($appName, $request); $this->config = $config; @@ -65,47 +70,114 @@ class EmailRecoveryController extends Controller { $this->l = $l; $this->userSession = $userSession; $this->recoveryEmailService = $recoveryEmailService; + $this->userManager = $userManager; + $this->verificationToken = $verificationToken; + $this->crypto = $crypto; } /** * @NoAdminRequired */ - public function getRecoveryEmail() { - $response = new JSONResponse(); - $userId = $this->userSession->getUser()->getUID(); - $data = array("recoveryEmail" => $this->config->getUserValue($userId, $this->appName, 'recovery-email')); - $response->setData($data); - return $response; + public function getRecoveryEmail() { + $response = new JSONResponse(); + $userId = $this->userSession->getUser()->getUID(); + $recoveryEmail = $this->config->getUserValue($userId, $this->appName, 'recovery-email'); + $unverifiedRecoveryEmail = $this->config->getUserValue($userId, $this->appName, 'unverified-recovery-email'); + $data = array("recoveryEmail" => $recoveryEmail, "unverifiedRecoveryEmail" => $unverifiedRecoveryEmail); + $response->setData($data); + return $response; + } + + /** + * @NoAdminRequired + * @PublicPage + * @NoCSRFRequired + */ + public function verifyRecoveryEmail(string $token, string $userId): TemplateResponse { + try { + //decrypt email + $email = $this->recoveryEmailService->getUnverifiedRecoveryEmail($userId); + $ref = substr(hash('sha256', $email), 0, 8); + + $user = $this->userManager->get($userId); + $verificationKey = 'verifyRecoveryMail' . $ref; + + $this->recoveryEmailService->verifyToken($token, $user, $verificationKey, $email); + + $this->recoveryEmailService->makeRecoveryEmailVerified($userId); + + $this->recoveryEmailService->deleteVerificationToken($token, $user, $verificationKey); + + $responseParams = [ + 'title' => $this->l->t('You verified recovery email successfully.'), + 'message' => $this->l->t('You verified recovery email successfully.'), + ]; + + return new TemplateResponse('core', 'success', $responseParams, TemplateResponse::RENDER_AS_GUEST); + } catch (InvalidTokenException $e) { + $error = $e->getCode() === InvalidTokenException::TOKEN_EXPIRED + ? $this->l->t('Could not verify recovery email because the token is expired') + : $this->l->t('Could not verify recovery email because the token is invalid'); + + $errorParams = [ + 'errors' => [['error' => $error]], + ]; + + return new TemplateResponse('core', 'error', $errorParams, TemplateResponse::RENDER_AS_GUEST); + } } + + /** * @NoAdminRequired */ public function setRecoveryEmail(string $recoveryEmail) { $userId = $this->userSession->getUser()->getUID(); - $response = new Response(); - try { - if ($this->recoveryEmailService->validateRecoveryEmail($userId, $recoveryEmail)) { - $this->recoveryEmailService->updateRecoveryEmail($userId, $recoveryEmail); - $response->setStatus(200); - return $response; - } - } catch (Exception $e) { - $response->setStatus(500); - if ($e instanceof InvalidRecoveryEmailException) { - $response->setStatus(400); - $this->l->t('Invalid Recovery Email'); - $response->setData(['message' => 'Invalid Recovery Email']); - } - if ($e instanceof SameRecoveryEmailAsEmailException) { - $response->setStatus(400); - $this->l->t('Error! User email address cannot be saved as recovery email address!'); - $response->setData(['message' => 'Error! User email address cannot be saved as recovery email address!']); - } - - $this->logger->error("Error setting recovery email for user $userId" . $e->getMessage()); - return $response; - } + $response = new JSONResponse(); + $this->handleRecoveryEmailLogic($recoveryEmail, $userId, $response); + return $response; } + + /** + * @NoAdminRequired + */ + public function resendRecoveryEmail(string $recoveryEmail) { + $response = new JSONResponse(); + $response->setStatus(200); + + $userId = $this->userSession->getUser()->getUID(); + $currentRecoveryEmail = $this->recoveryEmailService->getRecoveryEmail($userId); + if ($currentRecoveryEmail === $recoveryEmail) { + $response->setStatus(400); + $response->setData(['message' => $this->l->t('Recovery email is verified.')]); + return $response; + } + $this->recoveryEmailService->sendVerificationEmail($userId, $recoveryEmail); + return $response; + } + + private function handleRecoveryEmailLogic(string $recoveryEmail, string $userId, JSONResponse $response) { + try { + if ($this->recoveryEmailService->validateRecoveryEmail($userId, $recoveryEmail)) { + $this->recoveryEmailService->updateRecoveryEmail($userId, $recoveryEmail); + $response->setStatus(200); + } + } catch (Exception $e) { + $response->setStatus(500); + if ($e instanceof InvalidRecoveryEmailException) { + $response->setStatus(400); + $response->setData(['message' => $this->l->t('Invalid Recovery Email')]); + } + if ($e instanceof SameRecoveryEmailAsEmailException) { + $response->setStatus(400); + $response->setData(['message' => $this->l->t('Error! User email address cannot be saved as recovery email address!')]); + } + if ($e instanceof RecoveryEmailAlreadyFoundException) { + $response->setStatus(400); + $response->setData(['message' => $this->l->t('Recovery email address is already taken.')]); + } + } + } } diff --git a/lib/Exception/RecoveryEmailAlreadyFoundException.php b/lib/Exception/RecoveryEmailAlreadyFoundException.php new file mode 100644 index 0000000000000000000000000000000000000000..67d5cbbcaeed6903a2821bb56ed9c475d3fcab98 --- /dev/null +++ b/lib/Exception/RecoveryEmailAlreadyFoundException.php @@ -0,0 +1,11 @@ +logger = $logger; + $this->recoveryEmailService = $recoveryEmailService; + } + + public function handle(Event $event): void { + if (!($event instanceof UserConfigChangedEvent)) { + return; + } + if ($event->getKey() === 'unverified-recovery-email') { + $user = $event->getUserId(); + $newRecoveryEmail = $event->getValue(); + if ($newRecoveryEmail !== '') { + $this->recoveryEmailService->setRecoveryEmail($user, ''); + $this->recoveryEmailService->sendVerificationEmail($user, $newRecoveryEmail); + } + } + } +} diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index 460b7e84cf539cf69713d7f6ac0469f6b6ee29de..31f3156da87c2739535ca521071f49557e7a8d26 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -10,26 +10,57 @@ use OCP\IConfig; use OCP\IUserManager; use OCA\EmailRecovery\Exception\InvalidRecoveryEmailException; use OCA\EmailRecovery\Exception\SameRecoveryEmailAsEmailException; +use OCA\EmailRecovery\Exception\RecoveryEmailAlreadyFoundException; use OCA\EcloudAccounts\Service\LDAPConnectionService; +use OCP\Mail\IEMailTemplate; +use OCP\Mail\IMailer; +use OCP\Util; +use OCP\IUser; +use OCP\L10N\IFactory; +use OCP\IURLGenerator; +use OCP\Defaults; +use OCP\Security\VerificationToken\IVerificationToken; class RecoveryEmailService { - private $LDAPConnectionService; - private $config; - private $appName; - private $userManager; + private ILogger $logger; + private IConfig $config; + private string $appName; + private LDAPConnectionService $LDAPConnectionService; + private IUserManager $userManager; + private IMailer $mailer; + private IFactory $l10nFactory; + private IURLGenerator $urlGenerator; + private Defaults $themingDefaults; + private IVerificationToken $verificationToken; + protected const TOKEN_LIFETIME = 60 * 30; // 30 minutes - public function __construct(string $appName, ILogger $logger, IConfig $config, LDAPConnectionService $LDAPConnectionService, IUserManager $userManager) { + public function __construct(string $appName, ILogger $logger, IConfig $config, LDAPConnectionService $LDAPConnectionService, IUserManager $userManager, IMailer $mailer, IFactory $l10nFactory, IURLGenerator $urlGenerator, Defaults $themingDefaults, IVerificationToken $verificationToken) { $this->logger = $logger; $this->config = $config; $this->appName = $appName; $this->LDAPConnectionService = $LDAPConnectionService; $this->userManager = $userManager; + $this->mailer = $mailer; + $this->l10nFactory = $l10nFactory; + $this->urlGenerator = $urlGenerator; + $this->themingDefaults = $themingDefaults; + $this->verificationToken = $verificationToken; + } + public function setRecoveryEmail(string $username, string $value = '') : void { + $this->config->setUserValue($username, $this->appName, 'recovery-email', $value); } - public function getRecoveryEmail(string $username) : string { return $this->config->getUserValue($username, $this->appName, 'recovery-email', ''); } - + public function setUnverifiedRecoveryEmail(string $username, string $value = '') : void { + $this->config->setUserValue($username, $this->appName, 'unverified-recovery-email', $value); + } + public function getUnverifiedRecoveryEmail(string $username) : string { + return $this->config->getUserValue($username, $this->appName, 'unverified-recovery-email', ''); + } + public function deleteUnverifiedRecoveryEmail(string $username) : void { + $this->config->deleteUserValue($username, $this->appName, 'unverified-recovery-email'); + } public function validateRecoveryEmail(string $username, string $recoveryEmail) : bool { $user = $this->userManager->get($username); $email = $user->getEMailAddress(); @@ -42,15 +73,43 @@ class RecoveryEmailService { $this->logger->info("User ID $username's requested recovery email is the same as email"); throw new SameRecoveryEmailAsEmailException(); } + if (!empty($recoveryEmail) && $this->isRecoveryEmailTaken($username, $recoveryEmail)) { + $this->logger->info("User ID $username's requested recovery email address is already taken"); + throw new RecoveryEmailAlreadyFoundException(); + } return true; } + public function isRecoveryEmailTaken(string $username, string $recoveryEmail): bool { + $recoveryEmail = strtolower($recoveryEmail); + + $currentRecoveryEmail = $this->getRecoveryEmail($username); + $currentUnverifiedRecoveryEmail = $this->getUnverifiedRecoveryEmail($username); + + if ($currentRecoveryEmail === $recoveryEmail || $currentUnverifiedRecoveryEmail === $recoveryEmail) { + return false; + } + + $usersWithEmailRecovery = $this->config->getUsersForUserValue('email-recovery', 'recovery-email', $recoveryEmail); + if (count($usersWithEmailRecovery)) { + return true; + } + + $usersWithUnverifiedRecovery = $this->config->getUsersForUserValue('email-recovery', 'unverified-recovery-email', $recoveryEmail); + if (count($usersWithUnverifiedRecovery)) { + return true; + } + + return false; + } + public function updateRecoveryEmail(string $username, string $recoveryEmail) : void { $user = $this->userManager->get($username); if ($this->LDAPConnectionService->isUserOnLDAPBackend($user) && $this->LDAPConnectionService->isLDAPEnabled()) { $this->updateRecoveryEmailAtLDAPServer($username, $recoveryEmail); } - $this->config->setUserValue($username, $this->appName, 'recovery-email', $recoveryEmail); + $this->setUnverifiedRecoveryEmail($username, $recoveryEmail); + $this->setRecoveryEmail($username, ''); } @@ -65,4 +124,76 @@ class RecoveryEmailService { } $this->LDAPConnectionService->closeLDAPConnection($conn); } + public function sendVerificationEmail(string $uid, string $recoveryEmailAddress) : void { + try { + $user = $this->userManager->get($uid); + $emailTemplate = $this->generateVerificationEmailTemplate($user, $recoveryEmailAddress); + + $email = $this->mailer->createMessage(); + $email->useTemplate($emailTemplate); + $email->setTo([$recoveryEmailAddress]); + $email->setFrom([Util::getDefaultEmailAddress('no-reply') => $this->themingDefaults->getName()]); + $this->mailer->send($email); + } catch (\Exception $e) { + $this->logger->error('Error sending notification email to user ' . $uid, ['exception' => $e]); + } + } + /** + * @param IUser $user + * @param string $recoveryEmailAddress + * @return IEMailTemplate + */ + public function generateVerificationEmailTemplate(IUser $user, string $recoveryEmailAddress) { + $userId = $user->getUID(); + + $lang = $this->config->getUserValue($userId, 'core', 'lang', null); + $l10n = $this->l10nFactory->get('settings', $lang); + + $token = $this->createToken($user, $recoveryEmailAddress); + $link = $this->urlGenerator->linkToRouteAbsolute($this->appName .'.email_recovery.verify_recovery_email', ['token' => $token,'userId' => $user->getUID()]); + $this->logger->error('EMAIL URL LINK: ' . $link); + $displayName = $user->getDisplayName(); + + $emailTemplate = $this->mailer->createEMailTemplate('recovery-email.confirmation', [ + 'link' => $link, + 'displayname' => $displayName, + 'userid' => $userId, + 'instancename' => $this->themingDefaults->getName(), + 'resetTokenGenerated' => true, + ]); + + $emailTemplate->setSubject($l10n->t('Recovery Email Update in Your %s Account', [$this->themingDefaults->getName()])); + $emailTemplate->addHeader(); + $emailTemplate->addHeading($l10n->t('Hello %s', [$displayName])); + $emailTemplate->addBodyText($l10n->t('This is to inform you that the recovery email for your %s account has been successfully updated.', [$this->themingDefaults->getName()])); + $emailTemplate->addBodyText($l10n->t('To verify your new recovery email, please click on the following button.')); + $leftButtonText = $l10n->t('Verify recovery email'); + $emailTemplate->addBodyButton( + $leftButtonText, + $link + ); + $emailTemplate->addBodyText($l10n->t('Please note that this link will be valid for the next 30 minutes.')); + $emailTemplate->addBodyText($l10n->t('If you did not initiate this change, please contact our support team immediately.')); + $emailTemplate->addBodyText($l10n->t('Thank you for choosing %s.', [$this->themingDefaults->getName()])); + $emailTemplate->addFooter('', $lang); + + return $emailTemplate; + } + private function createToken(IUser $user, string $recoveryEmail = ''): string { + $ref = \substr(hash('sha256', $recoveryEmail), 0, 8); + return $this->verificationToken->create($user, 'verifyRecoveryMail' . $ref, $recoveryEmail, self::TOKEN_LIFETIME); + } + public function verifyToken(string $token, IUser $user, string $verificationKey, string $email): void { + $this->verificationToken->check($token, $user, $verificationKey, $email); + } + public function deleteVerificationToken(string $token, IUser $user, string $verificationKey): void { + $this->verificationToken->delete($token, $user, $verificationKey); + } + public function makeRecoveryEmailVerified(string $userId): void { + $newRecoveryEmailAddress = $this->getUnverifiedRecoveryEmail($userId); + if ($newRecoveryEmailAddress !== '') { + $this->setRecoveryEmail($userId, $newRecoveryEmailAddress); + $this->deleteUnverifiedRecoveryEmail($userId); + } + } } diff --git a/lib/Settings/RecoveryEmailSettings.php b/lib/Settings/RecoveryEmailSettings.php index 1c990496884f1c17fc98a4b425ea6be0cb408257..d509046040a209680da475a9e6dfa670b2d2b355 100644 --- a/lib/Settings/RecoveryEmailSettings.php +++ b/lib/Settings/RecoveryEmailSettings.php @@ -48,8 +48,12 @@ class RecoveryEmailSettings implements ISettings { public function getForm(): TemplateResponse { $username = $this->userSession->getUser()->getUID(); $recoveryEmail = $this->recoveryEmailService->getRecoveryEmail($username); - + $unverifiedRecoveryEmail = $this->recoveryEmailService->getUnverifiedRecoveryEmail($username); + $recoveryEmailVerificationStatus = $recoveryEmail != '' ? true : false; + $this->initialState->provideInitialState('recoveryEmail', $recoveryEmail); + $this->initialState->provideInitialState('recoveryEmailVerificationStatus', $recoveryEmailVerificationStatus); + $this->initialState->provideInitialState('unverifiedRecoveryEmail', $unverifiedRecoveryEmail); return new TemplateResponse( $this->appName, 'email_recovery_settings' diff --git a/scss/main.scss b/scss/main.scss index 1e7ae3be823553791995774f86ab7102e8f21b33..dd154745f46b6be3ca104ccfca76c9c72f0caae3 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -27,13 +27,14 @@ width: 400px; } #recoveryEmail, - #recoveryButton { + #recoveryButton, + #resendRecoveryButton { flex-shrink: 1; width: 100%; min-width: 150px; } - #recoveryButton { + #recoveryButton, #resendRecoveryButton { margin-top: 15px; } } diff --git a/src/App.vue b/src/App.vue index 43751d265398f670cadc2b352d4ddbb28321fbe0..e2e340c93b6a2c25d9a6d330a39bef440dab9e6a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -9,27 +9,32 @@ import { loadState } from '@nextcloud/initial-state' export default { name: 'App', data() { + const recoveryEmail = loadState('email-recovery', 'recoveryEmail') + const unverifiedRecoveryEmail = loadState('email-recovery', 'unverifiedRecoveryEmail') + return { - recoveryEmail: loadState('email-recovery', 'recoveryEmail'), + recoveryEmail: recoveryEmail || unverifiedRecoveryEmail, + unverifiedRecoveryEmail, errorKey: '', showConfirmation: false, showError: false, placeholder: t('email-recovery', 'Recovery Email'), value: t('email-recovery', 'Change Recovery Email'), + recoveryEmailVerificationStatus: loadState('email-recovery', 'recoveryEmailVerificationStatus'), + apiInProgress: false, } }, - methods: { - getRecoveryEmail() { - axios - .get(generateUrl('/apps/email-recovery/get_recovery_email')) - .then(response => { - this.recoveryEmail = response.data.recoveryEmail - }) + computed: { + isButtonDisabled() { + return this.recoveryEmail === this.unverifiedRecoveryEmail || this.recoveryEmail === loadState('email-recovery', 'recoveryEmail') || this.recoveryEmail.trim() === '' || this.apiInProgress }, + }, + methods: { updateRecoveryEmail() { this.showConfirmation = false this.showError = false this.errorKey = '' + this.apiInProgress = true confirmPassword().then(() => { axios .post( @@ -39,21 +44,57 @@ export default { } ) .then(response => { + this.recoveryEmailVerificationStatus = false this.showConfirmation = true + this.unverifiedRecoveryEmail = this.recoveryEmail setTimeout(function() { this.showConfirmation = false }, 3000) }) .catch(err => { this.errorKey = 'Error setting recovery email' - if (err.response && err.response.message) { - this.errorKey = err.response.message + if (err.response && err.response.data.message) { + this.errorKey = err.response.data.message } this.showError = true - this.getRecoveryEmail() + }).finally(() => { + this.apiInProgress = false }) }) }, + resendVerificationEmail() { + this.showConfirmation = false + this.showError = false + this.errorKey = '' + this.apiInProgress = true + axios + .post( + generateUrl('/apps/email-recovery/resend_recovery_email'), + { + recoveryEmail: this.unverifiedRecoveryEmail, + } + ) + .then(response => { + this.recoveryEmailVerificationStatus = false + this.showConfirmation = true + setTimeout(function() { + this.showConfirmation = false + }, 3000) + }) + .catch(err => { + this.errorKey = 'Error sending recovery verification email' + if (err.response && err.response.data.message) { + this.errorKey = err.response.data.message + if (err.response.status === 400) { + this.errorKey = '' + this.recoveryEmailVerificationStatus = true + } + } + this.showError = true + }).finally(() => { + this.apiInProgress = false + }) + }, }, } diff --git a/src/main.html b/src/main.html index a354bff52e0fa9a44edcf2b6d0965f0572ba417f..0b865e3ff83989cca3c41d61eb4a9ed17ff91aca 100644 --- a/src/main.html +++ b/src/main.html @@ -3,29 +3,37 @@ {{ t("email-recovery", "Recovery Email") }}
- - + - + + + + +

- {{ t("email-recovery","Changes saved") }} + {{ t("email-recovery","Please check your inbox. An email has been sent to you for verification.") }}

- {{ t( "email-recovery", errorKey ) }} + {{ t( "email-recovery", errorKey ) }}