From 83ad715e76015f56a8d4f1631b96926f1ed4729a Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Tue, 5 Mar 2024 23:51:33 -0800 Subject: [PATCH 01/10] Disallowed murena domains as recovery email --- appinfo/info.xml | 2 +- l10n/de.js | 3 ++- l10n/de.json | 3 ++- l10n/de_DE.js | 3 ++- l10n/de_DE.json | 3 ++- l10n/en.js | 3 ++- l10n/en.json | 3 ++- l10n/es.js | 3 ++- l10n/es.json | 3 ++- l10n/fr.js | 3 ++- l10n/fr.json | 3 ++- l10n/it.js | 3 ++- l10n/it.json | 3 ++- lib/Controller/EmailRecoveryController.php | 5 ++++ .../MurenaDomainDisallowedException.php | 11 ++++++++ lib/Service/RecoveryEmailService.php | 25 +++++++++++++++++++ 16 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 lib/Exception/MurenaDomainDisallowedException.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 6076c77..f8ef2ce 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ Email Recovery Email Recovery App - 4.0.0 + 4.0.1 agpl MURENA SAS EmailRecovery diff --git a/l10n/de.js b/l10n/de.js index 8de0a57..dae82d4 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -8,6 +8,7 @@ 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", + "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de.json b/l10n/de.json index 44b9689..9b0dcfa 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -6,6 +6,7 @@ "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", + "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen." },"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 8de0a57..dae82d4 100644 --- a/l10n/de_DE.js +++ b/l10n/de_DE.js @@ -8,6 +8,7 @@ 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", + "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de_DE.json b/l10n/de_DE.json index 44b9689..9b0dcfa 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -6,6 +6,7 @@ "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", + "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen." },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/en.js b/l10n/en.js index 55e2c67..47938dc 100644 --- a/l10n/en.js +++ b/l10n/en.js @@ -24,6 +24,7 @@ OC.L10N.register( "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:", "Please set your recovery email address to use your email account without restrictions.": "Please set your recovery email address to use your email account without restrictions.", - "SET RECOVERY EMAIL NOW": "SET RECOVERY EMAIL NOW" + "SET RECOVERY EMAIL NOW": "SET RECOVERY EMAIL NOW", + "You cannot set an email address with a Murena domain as recovery email address.": "You cannot set an email address with a Murena domain as recovery email address." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/en.json b/l10n/en.json index b4b133a..5701614 100644 --- a/l10n/en.json +++ b/l10n/en.json @@ -25,7 +25,8 @@ "Please set your recovery email address to use your email account without restrictions.": "Please set your recovery email address to use your email account without restrictions.", "SET RECOVERY EMAIL NOW": "SET RECOVERY EMAIL NOW", "20240101_weekly_reminder_subject": "**Action required: Set up your recovery email**", - "20240101_weekly_reminder_body": "Dear **{username}**,\n\nFor security reasons you need to set a recovery email address for your Murena Cloud account. As you haven't done so yet, the usage of your email address is restricted. Please set and validate a recovery email address to remove all usage restriction on your email address.\n\n[SET MY RECOVERY EMAIL ADDRESS](https://murena.io/settings/user/security#recovery-email-form)" + "20240101_weekly_reminder_body": "Dear **{username}**,\n\nFor security reasons you need to set a recovery email address for your Murena Cloud account. As you haven't done so yet, the usage of your email address is restricted. Please set and validate a recovery email address to remove all usage restriction on your email address.\n\n[SET MY RECOVERY EMAIL ADDRESS](https://murena.io/settings/user/security#recovery-email-form)", + "You cannot set an email address with a Murena domain as recovery email address.": "You cannot set an email address with a Murena domain as recovery email address." }, "pluralForm": "nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/l10n/es.js b/l10n/es.js index ac209fc..9a1ca46 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -8,6 +8,7 @@ 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", + "You cannot set an email address with a Murena domain as recovery email address.": "No puede establecer una dirección de correo electrónico con un dominio de Murena como dirección de correo electrónico de recuperación." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/es.json b/l10n/es.json index 2941d98..bc4c83f 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -6,6 +6,7 @@ "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", + "You cannot set an email address with a Murena domain as recovery email address.": "No puede establecer una dirección de correo electrónico con un dominio de Murena como dirección de correo electrónico de recuperación." },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/fr.js b/l10n/fr.js index 4e31d62..9a71c05 100644 --- a/l10n/fr.js +++ b/l10n/fr.js @@ -8,6 +8,7 @@ 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", + "You cannot set an email address with a Murena domain as recovery email address.": "Vous ne pouvez pas définir une adresse électronique avec un domaine Murena comme adresse électronique de récupération." }, "nplurals=2; plural=n > 1;"); diff --git a/l10n/fr.json b/l10n/fr.json index c422d42..e1aad13 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -6,6 +6,7 @@ "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", + "You cannot set an email address with a Murena domain as recovery email address.": "Vous ne pouvez pas définir une adresse électronique avec un domaine Murena comme adresse électronique de récupération." },"pluralForm" :"nplurals=2; plural=n > 1;" } \ No newline at end of file diff --git a/l10n/it.js b/l10n/it.js index 02879b7..084c941 100644 --- a/l10n/it.js +++ b/l10n/it.js @@ -8,6 +8,7 @@ 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", + "You cannot set an email address with a Murena domain as recovery email address.": "Non è possibile impostare un indirizzo e-mail con un dominio Murena come indirizzo e-mail di recupero." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/it.json b/l10n/it.json index 2edf4b7..ecda10d 100644 --- a/l10n/it.json +++ b/l10n/it.json @@ -6,6 +6,7 @@ "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", + "You cannot set an email address with a Murena domain as recovery email address.": "Non è possibile impostare un indirizzo e-mail con un dominio Murena come indirizzo e-mail di recupero." },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/lib/Controller/EmailRecoveryController.php b/lib/Controller/EmailRecoveryController.php index 9fab9c7..3d4a22c 100644 --- a/lib/Controller/EmailRecoveryController.php +++ b/lib/Controller/EmailRecoveryController.php @@ -35,6 +35,7 @@ use OCA\EmailRecovery\Service\RecoveryEmailService; use OCA\EmailRecovery\Exception\InvalidRecoveryEmailException; use OCA\EmailRecovery\Exception\SameRecoveryEmailAsEmailException; use OCA\EmailRecovery\Exception\RecoveryEmailAlreadyFoundException; +use OCA\EmailRecovery\Exception\MurenaDomainDisallowedException; use OCP\IUserManager; use OCP\Security\VerificationToken\IVerificationToken; use OCP\Security\VerificationToken\InvalidTokenException; @@ -178,6 +179,10 @@ class EmailRecoveryController extends Controller { $response->setStatus(400); $response->setData(['message' => $this->l->t('Recovery email address is already taken.')]); } + if ($e instanceof MurenaDomainDisallowedException) { + $response->setStatus(400); + $response->setData(['message' => $this->l->t('You cannot set an email address with a Murena domain as recovery email address.')]); + } } } } diff --git a/lib/Exception/MurenaDomainDisallowedException.php b/lib/Exception/MurenaDomainDisallowedException.php new file mode 100644 index 0000000..6504d9b --- /dev/null +++ b/lib/Exception/MurenaDomainDisallowedException.php @@ -0,0 +1,11 @@ +logger->info("User ID $username's requested recovery email address is already taken"); throw new RecoveryEmailAlreadyFoundException(); } + if (!empty($recoveryEmail) && $this->isRecoveryEmailDomainDisallowed($recoveryEmail)) { + $this->logger->info("User ID $username's requested recovery email address is disallowed."); + throw new MurenaDomainDisallowedException(); + } return true; } + /** + * Check if a recovery email address domain is restricted for some domains + * + * @param string $recoveryEmail The recovery email address to check. + * + * @return bool True if the recovery email address is disallowed, false otherwise. + */ + public function isRecoveryEmailDomainDisallowed(string $recoveryEmail): bool { + + $recoveryEmail = strtolower($recoveryEmail); + + $emailParts = explode('@', $recoveryEmail); + $domain = $emailParts[1] ?? ''; + + $legacyDomain = $this->config->getSystemValue('legacy_domain', '');; + $mainDomain = $this->config->getSystemValue('main_domain', ''); + + $restrictedDomains = [ $legacyDomain, $mainDomain ]; + return in_array($domain, $restrictedDomains); + } public function isRecoveryEmailTaken(string $username, string $recoveryEmail): bool { $recoveryEmail = strtolower($recoveryEmail); -- GitLab From 50b8c515318540abbe459d03146d2b1569af9ee2 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Tue, 5 Mar 2024 23:55:08 -0800 Subject: [PATCH 02/10] lint --- lib/Service/RecoveryEmailService.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index 1249f12..11da893 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -5,22 +5,22 @@ declare(strict_types=1); namespace OCA\EmailRecovery\Service; use Exception; -use OCP\ILogger; -use OCP\IConfig; -use OCP\IUserManager; +use OCA\EcloudAccounts\Service\LDAPConnectionService; use OCA\EmailRecovery\Exception\InvalidRecoveryEmailException; -use OCA\EmailRecovery\Exception\SameRecoveryEmailAsEmailException; -use OCA\EmailRecovery\Exception\RecoveryEmailAlreadyFoundException; use OCA\EmailRecovery\Exception\MurenaDomainDisallowedException; -use OCA\EcloudAccounts\Service\LDAPConnectionService; -use OCP\Mail\IEMailTemplate; -use OCP\Mail\IMailer; -use OCP\Util; +use OCA\EmailRecovery\Exception\RecoveryEmailAlreadyFoundException; +use OCA\EmailRecovery\Exception\SameRecoveryEmailAsEmailException; +use OCP\Defaults; +use OCP\IConfig; +use OCP\ILogger; +use OCP\IURLGenerator; use OCP\IUser; +use OCP\IUserManager; use OCP\L10N\IFactory; -use OCP\IURLGenerator; -use OCP\Defaults; +use OCP\Mail\IEMailTemplate; +use OCP\Mail\IMailer; use OCP\Security\VerificationToken\IVerificationToken; +use OCP\Util; class RecoveryEmailService { private ILogger $logger; @@ -98,7 +98,8 @@ class RecoveryEmailService { $emailParts = explode('@', $recoveryEmail); $domain = $emailParts[1] ?? ''; - $legacyDomain = $this->config->getSystemValue('legacy_domain', '');; + $legacyDomain = $this->config->getSystemValue('legacy_domain', ''); + ; $mainDomain = $this->config->getSystemValue('main_domain', ''); $restrictedDomains = [ $legacyDomain, $mainDomain ]; -- GitLab From ddb4ab9e17cc3a61e88a0f5e6b3fb5e9b69a9dca Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Tue, 5 Mar 2024 23:56:50 -0800 Subject: [PATCH 03/10] lint --- lib/Service/RecoveryEmailService.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index 11da893..1249f12 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -5,22 +5,22 @@ declare(strict_types=1); namespace OCA\EmailRecovery\Service; use Exception; -use OCA\EcloudAccounts\Service\LDAPConnectionService; -use OCA\EmailRecovery\Exception\InvalidRecoveryEmailException; -use OCA\EmailRecovery\Exception\MurenaDomainDisallowedException; -use OCA\EmailRecovery\Exception\RecoveryEmailAlreadyFoundException; -use OCA\EmailRecovery\Exception\SameRecoveryEmailAsEmailException; -use OCP\Defaults; -use OCP\IConfig; use OCP\ILogger; -use OCP\IURLGenerator; -use OCP\IUser; +use OCP\IConfig; use OCP\IUserManager; -use OCP\L10N\IFactory; +use OCA\EmailRecovery\Exception\InvalidRecoveryEmailException; +use OCA\EmailRecovery\Exception\SameRecoveryEmailAsEmailException; +use OCA\EmailRecovery\Exception\RecoveryEmailAlreadyFoundException; +use OCA\EmailRecovery\Exception\MurenaDomainDisallowedException; +use OCA\EcloudAccounts\Service\LDAPConnectionService; use OCP\Mail\IEMailTemplate; use OCP\Mail\IMailer; -use OCP\Security\VerificationToken\IVerificationToken; use OCP\Util; +use OCP\IUser; +use OCP\L10N\IFactory; +use OCP\IURLGenerator; +use OCP\Defaults; +use OCP\Security\VerificationToken\IVerificationToken; class RecoveryEmailService { private ILogger $logger; @@ -98,8 +98,7 @@ class RecoveryEmailService { $emailParts = explode('@', $recoveryEmail); $domain = $emailParts[1] ?? ''; - $legacyDomain = $this->config->getSystemValue('legacy_domain', ''); - ; + $legacyDomain = $this->config->getSystemValue('legacy_domain', '');; $mainDomain = $this->config->getSystemValue('main_domain', ''); $restrictedDomains = [ $legacyDomain, $mainDomain ]; -- GitLab From 30211697644d32f9b90f663a08332fe9755e2a8c Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Tue, 5 Mar 2024 23:59:24 -0800 Subject: [PATCH 04/10] lint issue --- lib/Service/RecoveryEmailService.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index 1249f12..25eb690 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -84,24 +84,16 @@ class RecoveryEmailService { } return true; } - /** - * Check if a recovery email address domain is restricted for some domains - * - * @param string $recoveryEmail The recovery email address to check. - * - * @return bool True if the recovery email address is disallowed, false otherwise. - */ public function isRecoveryEmailDomainDisallowed(string $recoveryEmail): bool { - $recoveryEmail = strtolower($recoveryEmail); - $emailParts = explode('@', $recoveryEmail); $domain = $emailParts[1] ?? ''; + + $legacyDomain = $this->config->getSystemValue('legacy_domain', ''); - $legacyDomain = $this->config->getSystemValue('legacy_domain', '');; $mainDomain = $this->config->getSystemValue('main_domain', ''); - - $restrictedDomains = [ $legacyDomain, $mainDomain ]; + + $restrictedDomains = [$legacyDomain, $mainDomain]; return in_array($domain, $restrictedDomains); } -- GitLab From fa1b122e415d203b259ba4ba1b7a4859c65e629f Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 6 Mar 2024 00:01:01 -0800 Subject: [PATCH 05/10] lint issue --- lib/Controller/EmailRecoveryController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Controller/EmailRecoveryController.php b/lib/Controller/EmailRecoveryController.php index 3d4a22c..46e88ff 100644 --- a/lib/Controller/EmailRecoveryController.php +++ b/lib/Controller/EmailRecoveryController.php @@ -179,7 +179,7 @@ class EmailRecoveryController extends Controller { $response->setStatus(400); $response->setData(['message' => $this->l->t('Recovery email address is already taken.')]); } - if ($e instanceof MurenaDomainDisallowedException) { + if ($e instanceof MurenaDomainDisallowedException) { $response->setStatus(400); $response->setData(['message' => $this->l->t('You cannot set an email address with a Murena domain as recovery email address.')]); } -- GitLab From e2efa0bd6814fc210eb233e91a4a629844d9512b Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 6 Mar 2024 00:01:41 -0800 Subject: [PATCH 06/10] lint issue --- lib/Controller/EmailRecoveryController.php | 114 ++++++++++----------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/lib/Controller/EmailRecoveryController.php b/lib/Controller/EmailRecoveryController.php index 46e88ff..9a29776 100644 --- a/lib/Controller/EmailRecoveryController.php +++ b/lib/Controller/EmailRecoveryController.php @@ -24,24 +24,24 @@ namespace OCA\EmailRecovery\Controller; +use Exception; +use OCA\EmailRecovery\Exception\InvalidRecoveryEmailException; +use OCA\EmailRecovery\Exception\MurenaDomainDisallowedException; +use OCA\EmailRecovery\Exception\RecoveryEmailAlreadyFoundException; +use OCA\EmailRecovery\Exception\SameRecoveryEmailAsEmailException; +use OCA\EmailRecovery\Service\RecoveryEmailService; use OCP\AppFramework\Controller; -use OCP\IRequest; +use OCP\AppFramework\Http\JSONResponse; +use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; +use OCP\IL10N; use OCP\ILogger; -use \OCP\IL10N; -use OCP\IUserSession; -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 OCA\EmailRecovery\Exception\MurenaDomainDisallowedException; +use OCP\IRequest; use OCP\IUserManager; -use OCP\Security\VerificationToken\IVerificationToken; -use OCP\Security\VerificationToken\InvalidTokenException; -use Exception; -use OCP\AppFramework\Http\TemplateResponse; +use OCP\IUserSession; use OCP\Security\ICrypto; +use OCP\Security\VerificationToken\InvalidTokenException; +use OCP\Security\VerificationToken\IVerificationToken; class EmailRecoveryController extends Controller { private IConfig $config; @@ -80,15 +80,15 @@ class EmailRecoveryController extends Controller { * @NoAdminRequired */ - 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; - } + 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 = ["recoveryEmail" => $recoveryEmail, "unverifiedRecoveryEmail" => $unverifiedRecoveryEmail]; + $response->setData($data); + return $response; + } /** * @NoAdminRequired @@ -144,45 +144,45 @@ class EmailRecoveryController extends Controller { /** * @NoAdminRequired */ - public function resendRecoveryEmail(string $recoveryEmail) { - $response = new JSONResponse(); - $response->setStatus(200); + 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; - } + $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.')]); - } + 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.')]); + } if ($e instanceof MurenaDomainDisallowedException) { $response->setStatus(400); $response->setData(['message' => $this->l->t('You cannot set an email address with a Murena domain as recovery email address.')]); } - } - } + } + } } -- GitLab From f983711d8e3d1b02fd837a515e4e8fa7bd4ba565 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 6 Mar 2024 00:11:10 -0800 Subject: [PATCH 07/10] recovery email translation --- l10n/de.js | 3 ++- l10n/de.json | 3 ++- l10n/de_DE.js | 3 ++- l10n/de_DE.json | 3 ++- l10n/es.js | 3 ++- l10n/es.json | 3 ++- l10n/fr.js | 3 ++- l10n/fr.json | 3 ++- l10n/it.js | 3 ++- l10n/it.json | 3 ++- 10 files changed, 20 insertions(+), 10 deletions(-) diff --git a/l10n/de.js b/l10n/de.js index dae82d4..eec0a75 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -9,6 +9,7 @@ OC.L10N.register( "Change Recovery Email" : "Wiederherstellungs-E-Mail ändern", "Recovery Email " : "Wiederherstellungs-E-Mail ", "Changes saved" : "Änderungen gespeichert", - "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen." + "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", + "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de.json b/l10n/de.json index 9b0dcfa..a298169 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -7,6 +7,7 @@ "Change Recovery Email" : "Wiederherstellungs-E-Mail ändern", "Recovery Email " : "Wiederherstellungs-E-Mail ", "Changes saved" : "Änderungen gespeichert", - "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen." + "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", + "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft." },"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 dae82d4..eec0a75 100644 --- a/l10n/de_DE.js +++ b/l10n/de_DE.js @@ -9,6 +9,7 @@ OC.L10N.register( "Change Recovery Email" : "Wiederherstellungs-E-Mail ändern", "Recovery Email " : "Wiederherstellungs-E-Mail ", "Changes saved" : "Änderungen gespeichert", - "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen." + "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", + "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de_DE.json b/l10n/de_DE.json index 9b0dcfa..a298169 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -7,6 +7,7 @@ "Change Recovery Email" : "Wiederherstellungs-E-Mail ändern", "Recovery Email " : "Wiederherstellungs-E-Mail ", "Changes saved" : "Änderungen gespeichert", - "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen." + "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", + "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft." },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/es.js b/l10n/es.js index 9a1ca46..3875c31 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -9,6 +9,7 @@ OC.L10N.register( "Change Recovery Email" : "Cambiar correo electrónico de recuperación", "Recovery Email " : "Correo electrónico de recuperación ", "Changes saved" : "Cambios guardados", - "You cannot set an email address with a Murena domain as recovery email address.": "No puede establecer una dirección de correo electrónico con un dominio de Murena como dirección de correo electrónico de recuperación." + "You cannot set an email address with a Murena domain as recovery email address.": "No puede establecer una dirección de correo electrónico con un dominio de Murena como dirección de correo electrónico de recuperación.", + "Recovery email is not verified.": "El correo electrónico de recuperación no está verificado." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/es.json b/l10n/es.json index bc4c83f..83e12da 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -7,6 +7,7 @@ "Change Recovery Email" : "Cambiar correo electrónico de recuperación", "Recovery Email " : "Correo electrónico de recuperación ", "Changes saved" : "Cambios guardados", - "You cannot set an email address with a Murena domain as recovery email address.": "No puede establecer una dirección de correo electrónico con un dominio de Murena como dirección de correo electrónico de recuperación." + "You cannot set an email address with a Murena domain as recovery email address.": "No puede establecer una dirección de correo electrónico con un dominio de Murena como dirección de correo electrónico de recuperación.", + "Recovery email is not verified.": "El correo electrónico de recuperación no está verificado." },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/fr.js b/l10n/fr.js index 9a71c05..c536f5f 100644 --- a/l10n/fr.js +++ b/l10n/fr.js @@ -9,6 +9,7 @@ OC.L10N.register( "Change Recovery Email" : "Modifier le courriel de récupération", "Recovery Email " : "Courriel de récupération ", "Changes saved" : "Changements enregistrés", - "You cannot set an email address with a Murena domain as recovery email address.": "Vous ne pouvez pas définir une adresse électronique avec un domaine Murena comme adresse électronique de récupération." + "You cannot set an email address with a Murena domain as recovery email address.": "Vous ne pouvez pas définir une adresse électronique avec un domaine Murena comme adresse électronique de récupération.", + "Recovery email is not verified.": "L'email de récupération n'est pas vérifié." }, "nplurals=2; plural=n > 1;"); diff --git a/l10n/fr.json b/l10n/fr.json index e1aad13..a10528b 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -7,6 +7,7 @@ "Change Recovery Email" : "Modifier le courriel de récupération", "Recovery Email " : "Courriel de récupération ", "Changes saved" : "Changements enregistrés", - "You cannot set an email address with a Murena domain as recovery email address.": "Vous ne pouvez pas définir une adresse électronique avec un domaine Murena comme adresse électronique de récupération." + "You cannot set an email address with a Murena domain as recovery email address.": "Vous ne pouvez pas définir une adresse électronique avec un domaine Murena comme adresse électronique de récupération.", + "Recovery email is not verified.": "L'email de récupération n'est pas 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 084c941..85118e6 100644 --- a/l10n/it.js +++ b/l10n/it.js @@ -9,6 +9,7 @@ OC.L10N.register( "Change Recovery Email" : "Modifica dell'e-mail di recupero", "Recovery Email " : "Recupero e-mail ", "Changes saved" : "Modifiche salvate", - "You cannot set an email address with a Murena domain as recovery email address.": "Non è possibile impostare un indirizzo e-mail con un dominio Murena come indirizzo e-mail di recupero." + "You cannot set an email address with a Murena domain as recovery email address.": "Non è possibile impostare un indirizzo e-mail con un dominio Murena come indirizzo e-mail di recupero.", + "Recovery email is not verified.": "L'e-mail di recupero non è verificata." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/it.json b/l10n/it.json index ecda10d..4a3d558 100644 --- a/l10n/it.json +++ b/l10n/it.json @@ -7,6 +7,7 @@ "Change Recovery Email" : "Modifica dell'e-mail di recupero", "Recovery Email " : "Recupero e-mail ", "Changes saved" : "Modifiche salvate", - "You cannot set an email address with a Murena domain as recovery email address.": "Non è possibile impostare un indirizzo e-mail con un dominio Murena come indirizzo e-mail di recupero." + "You cannot set an email address with a Murena domain as recovery email address.": "Non è possibile impostare un indirizzo e-mail con un dominio Murena come indirizzo e-mail di recupero.", + "Recovery email is not verified.": "L'e-mail di recupero non è verificata." },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file -- GitLab From fca8af9edf2f03499abd282df6895337f0b3fef3 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 6 Mar 2024 00:13:35 -0800 Subject: [PATCH 08/10] recovery email translation --- l10n/de.js | 3 ++- l10n/de.json | 3 ++- l10n/de_DE.js | 3 ++- l10n/de_DE.json | 3 ++- l10n/es.js | 3 ++- l10n/es.json | 3 ++- l10n/fr.js | 3 ++- l10n/fr.json | 3 ++- l10n/it.js | 3 ++- l10n/it.json | 3 ++- 10 files changed, 20 insertions(+), 10 deletions(-) diff --git a/l10n/de.js b/l10n/de.js index eec0a75..ef5602a 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -10,6 +10,7 @@ OC.L10N.register( "Recovery Email " : "Wiederherstellungs-E-Mail ", "Changes saved" : "Änderungen gespeichert", "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", - "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft." + "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft.", + "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de.json b/l10n/de.json index a298169..f9094cd 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -8,6 +8,7 @@ "Recovery Email " : "Wiederherstellungs-E-Mail ", "Changes saved" : "Änderungen gespeichert", "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", - "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft." + "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft.", + "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben." },"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 eec0a75..ef5602a 100644 --- a/l10n/de_DE.js +++ b/l10n/de_DE.js @@ -10,6 +10,7 @@ OC.L10N.register( "Recovery Email " : "Wiederherstellungs-E-Mail ", "Changes saved" : "Änderungen gespeichert", "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", - "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft." + "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft.", + "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de_DE.json b/l10n/de_DE.json index a298169..f9094cd 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -8,6 +8,7 @@ "Recovery Email " : "Wiederherstellungs-E-Mail ", "Changes saved" : "Änderungen gespeichert", "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", - "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft." + "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft.", + "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben." },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/es.js b/l10n/es.js index 3875c31..020f07a 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -10,6 +10,7 @@ OC.L10N.register( "Recovery Email " : "Correo electrónico de recuperación ", "Changes saved" : "Cambios guardados", "You cannot set an email address with a Murena domain as recovery email address.": "No puede establecer una dirección de correo electrónico con un dominio de Murena como dirección de correo electrónico de recuperación.", - "Recovery email is not verified.": "El correo electrónico de recuperación no está verificado." + "Recovery email is not verified.": "El correo electrónico de recuperación no está verificado.", + "Recovery email address is already taken.": "La dirección de correo electrónico de recuperación ya está ocupada." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/es.json b/l10n/es.json index 83e12da..81f5544 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -8,6 +8,7 @@ "Recovery Email " : "Correo electrónico de recuperación ", "Changes saved" : "Cambios guardados", "You cannot set an email address with a Murena domain as recovery email address.": "No puede establecer una dirección de correo electrónico con un dominio de Murena como dirección de correo electrónico de recuperación.", - "Recovery email is not verified.": "El correo electrónico de recuperación no está verificado." + "Recovery email is not verified.": "El correo electrónico de recuperación no está verificado.", + "Recovery email address is already taken.": "La dirección de correo electrónico de recuperación ya está ocupada." },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/fr.js b/l10n/fr.js index c536f5f..b4329b6 100644 --- a/l10n/fr.js +++ b/l10n/fr.js @@ -10,6 +10,7 @@ OC.L10N.register( "Recovery Email " : "Courriel de récupération ", "Changes saved" : "Changements enregistrés", "You cannot set an email address with a Murena domain as recovery email address.": "Vous ne pouvez pas définir une adresse électronique avec un domaine Murena comme adresse électronique de récupération.", - "Recovery email is not verified.": "L'email de récupération n'est pas vérifié." + "Recovery email is not verified.": "L'email de récupération n'est pas vérifié.", + "Recovery email address is already taken.": "L'adresse électronique de récupération est déjà prise." }, "nplurals=2; plural=n > 1;"); diff --git a/l10n/fr.json b/l10n/fr.json index a10528b..f5c5145 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -8,6 +8,7 @@ "Recovery Email " : "Courriel de récupération ", "Changes saved" : "Changements enregistrés", "You cannot set an email address with a Murena domain as recovery email address.": "Vous ne pouvez pas définir une adresse électronique avec un domaine Murena comme adresse électronique de récupération.", - "Recovery email is not verified.": "L'email de récupération n'est pas vérifié." + "Recovery email is not verified.": "L'email de récupération n'est pas vérifié.", + "Recovery email address is already taken.": "L'adresse électronique de récupération est déjà prise." },"pluralForm" :"nplurals=2; plural=n > 1;" } \ No newline at end of file diff --git a/l10n/it.js b/l10n/it.js index 85118e6..6e9ced0 100644 --- a/l10n/it.js +++ b/l10n/it.js @@ -10,6 +10,7 @@ OC.L10N.register( "Recovery Email " : "Recupero e-mail ", "Changes saved" : "Modifiche salvate", "You cannot set an email address with a Murena domain as recovery email address.": "Non è possibile impostare un indirizzo e-mail con un dominio Murena come indirizzo e-mail di recupero.", - "Recovery email is not verified.": "L'e-mail di recupero non è verificata." + "Recovery email is not verified.": "L'e-mail di recupero non è verificata.", + "Recovery email address is already taken.": "L'indirizzo e-mail di recupero è già stato preso." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/it.json b/l10n/it.json index 4a3d558..7ae6802 100644 --- a/l10n/it.json +++ b/l10n/it.json @@ -8,6 +8,7 @@ "Recovery Email " : "Recupero e-mail ", "Changes saved" : "Modifiche salvate", "You cannot set an email address with a Murena domain as recovery email address.": "Non è possibile impostare un indirizzo e-mail con un dominio Murena come indirizzo e-mail di recupero.", - "Recovery email is not verified.": "L'e-mail di recupero non è verificata." + "Recovery email is not verified.": "L'e-mail di recupero non è verificata.", + "Recovery email address is already taken.": "L'indirizzo e-mail di recupero è già stato preso." },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file -- GitLab From 5bed73687e5574f5f14eef185bd928e74ff0a097 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 6 Mar 2024 00:17:58 -0800 Subject: [PATCH 09/10] recovery email translation --- l10n/de.js | 3 ++- l10n/de.json | 3 ++- l10n/de_DE.js | 3 ++- l10n/de_DE.json | 3 ++- l10n/es.js | 3 ++- l10n/es.json | 3 ++- l10n/fr.js | 3 ++- l10n/fr.json | 3 ++- l10n/it.js | 3 ++- l10n/it.json | 3 ++- 10 files changed, 20 insertions(+), 10 deletions(-) diff --git a/l10n/de.js b/l10n/de.js index ef5602a..1147ba5 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -11,6 +11,7 @@ OC.L10N.register( "Changes saved" : "Änderungen gespeichert", "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft.", - "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben." + "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben.", + "Resend Verification Email": "Verifizierungs-E-Mail erneut senden" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de.json b/l10n/de.json index f9094cd..516d4dd 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -9,6 +9,7 @@ "Changes saved" : "Änderungen gespeichert", "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft.", - "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben." + "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben.", + "Resend Verification Email": "Verifizierungs-E-Mail erneut senden" },"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 ef5602a..1147ba5 100644 --- a/l10n/de_DE.js +++ b/l10n/de_DE.js @@ -11,6 +11,7 @@ OC.L10N.register( "Changes saved" : "Änderungen gespeichert", "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft.", - "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben." + "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben.", + "Resend Verification Email": "Verifizierungs-E-Mail erneut senden" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de_DE.json b/l10n/de_DE.json index f9094cd..516d4dd 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -9,6 +9,7 @@ "Changes saved" : "Änderungen gespeichert", "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", "Recovery email is not verified.": "Die Wiederherstellungs-E-Mail wird nicht überprüft.", - "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben." + "Recovery email address is already taken.": "Die E-Mail-Adresse für die Wiederherstellung ist bereits vergeben.", + "Resend Verification Email": "Verifizierungs-E-Mail erneut senden" },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/es.js b/l10n/es.js index 020f07a..9ed8198 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -11,6 +11,7 @@ OC.L10N.register( "Changes saved" : "Cambios guardados", "You cannot set an email address with a Murena domain as recovery email address.": "No puede establecer una dirección de correo electrónico con un dominio de Murena como dirección de correo electrónico de recuperación.", "Recovery email is not verified.": "El correo electrónico de recuperación no está verificado.", - "Recovery email address is already taken.": "La dirección de correo electrónico de recuperación ya está ocupada." + "Recovery email address is already taken.": "La dirección de correo electrónico de recuperación ya está ocupada.", + "Resend Verification Email": "Reenviar correo de verificación" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/es.json b/l10n/es.json index 81f5544..3e8fae3 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -9,6 +9,7 @@ "Changes saved" : "Cambios guardados", "You cannot set an email address with a Murena domain as recovery email address.": "No puede establecer una dirección de correo electrónico con un dominio de Murena como dirección de correo electrónico de recuperación.", "Recovery email is not verified.": "El correo electrónico de recuperación no está verificado.", - "Recovery email address is already taken.": "La dirección de correo electrónico de recuperación ya está ocupada." + "Recovery email address is already taken.": "La dirección de correo electrónico de recuperación ya está ocupada.", + "Resend Verification Email": "Reenviar correo de verificación" },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/fr.js b/l10n/fr.js index b4329b6..809296d 100644 --- a/l10n/fr.js +++ b/l10n/fr.js @@ -11,6 +11,7 @@ OC.L10N.register( "Changes saved" : "Changements enregistrés", "You cannot set an email address with a Murena domain as recovery email address.": "Vous ne pouvez pas définir une adresse électronique avec un domaine Murena comme adresse électronique de récupération.", "Recovery email is not verified.": "L'email de récupération n'est pas vérifié.", - "Recovery email address is already taken.": "L'adresse électronique de récupération est déjà prise." + "Recovery email address is already taken.": "L'adresse électronique de récupération est déjà prise.", + "Resend Verification Email": "Renvoyer l'e-mail de vérification" }, "nplurals=2; plural=n > 1;"); diff --git a/l10n/fr.json b/l10n/fr.json index f5c5145..2cbd8e1 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -9,6 +9,7 @@ "Changes saved" : "Changements enregistrés", "You cannot set an email address with a Murena domain as recovery email address.": "Vous ne pouvez pas définir une adresse électronique avec un domaine Murena comme adresse électronique de récupération.", "Recovery email is not verified.": "L'email de récupération n'est pas vérifié.", - "Recovery email address is already taken.": "L'adresse électronique de récupération est déjà prise." + "Recovery email address is already taken.": "L'adresse électronique de récupération est déjà prise.", + "Resend Verification Email": "Renvoyer l'e-mail de vérification" },"pluralForm" :"nplurals=2; plural=n > 1;" } \ No newline at end of file diff --git a/l10n/it.js b/l10n/it.js index 6e9ced0..2d849db 100644 --- a/l10n/it.js +++ b/l10n/it.js @@ -11,6 +11,7 @@ OC.L10N.register( "Changes saved" : "Modifiche salvate", "You cannot set an email address with a Murena domain as recovery email address.": "Non è possibile impostare un indirizzo e-mail con un dominio Murena come indirizzo e-mail di recupero.", "Recovery email is not verified.": "L'e-mail di recupero non è verificata.", - "Recovery email address is already taken.": "L'indirizzo e-mail di recupero è già stato preso." + "Recovery email address is already taken.": "L'indirizzo e-mail di recupero è già stato preso.", + "Resend Verification Email": "Reinvio dell'e-mail di verifica" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/it.json b/l10n/it.json index 7ae6802..1277336 100644 --- a/l10n/it.json +++ b/l10n/it.json @@ -9,6 +9,7 @@ "Changes saved" : "Modifiche salvate", "You cannot set an email address with a Murena domain as recovery email address.": "Non è possibile impostare un indirizzo e-mail con un dominio Murena come indirizzo e-mail di recupero.", "Recovery email is not verified.": "L'e-mail di recupero non è verificata.", - "Recovery email address is already taken.": "L'indirizzo e-mail di recupero è già stato preso." + "Recovery email address is already taken.": "L'indirizzo e-mail di recupero è già stato preso.", + "Resend Verification Email": "Reinvio dell'e-mail di verifica" },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file -- GitLab From 5cc43caa82ad552f9912a3a4ba32adec87b5fdbd Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 6 Mar 2024 21:37:21 -0800 Subject: [PATCH 10/10] added empty condition at top --- lib/Service/RecoveryEmailService.php | 33 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index 25eb690..23c4d32 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -65,22 +65,23 @@ class RecoveryEmailService { public function validateRecoveryEmail(string $username, string $recoveryEmail) : bool { $user = $this->userManager->get($username); $email = $user->getEMailAddress(); - - if (!filter_var($recoveryEmail, FILTER_VALIDATE_EMAIL)) { - $this->logger->info("User $username's requested recovery email does not match email format"); - throw new InvalidRecoveryEmailException(); - } - if (strcmp($recoveryEmail, $email) === 0) { - $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(); - } - if (!empty($recoveryEmail) && $this->isRecoveryEmailDomainDisallowed($recoveryEmail)) { - $this->logger->info("User ID $username's requested recovery email address is disallowed."); - throw new MurenaDomainDisallowedException(); + if (!empty($recoveryEmail)) { + if (!filter_var($recoveryEmail, FILTER_VALIDATE_EMAIL)) { + $this->logger->info("User $username's requested recovery email does not match email format"); + throw new InvalidRecoveryEmailException(); + } + if (strcmp($recoveryEmail, $email) === 0) { + $this->logger->info("User ID $username's requested recovery email is the same as email"); + throw new SameRecoveryEmailAsEmailException(); + } + if ($this->isRecoveryEmailTaken($username, $recoveryEmail)) { + $this->logger->info("User ID $username's requested recovery email address is already taken"); + throw new RecoveryEmailAlreadyFoundException(); + } + if ($this->isRecoveryEmailDomainDisallowed($recoveryEmail)) { + $this->logger->info("User ID $username's requested recovery email address is disallowed."); + throw new MurenaDomainDisallowedException(); + } } return true; } -- GitLab