diff --git a/l10n/de.js b/l10n/de.js index 5caf16daa9ab11adcebdae0121152b862afffceb..a1231789fd9834466a4536c30f5412e9c33bf299 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -31,6 +31,7 @@ OC.L10N.register( "Could not verify recovery email because the token is expired": "Wiederherstellungs-E-Mail konnte nicht überprüft werden, da das Token abgelaufen ist", "Could not verify recovery email because the token is invalid": "Wiederherstellungs-E-Mail konnte nicht überprüft werden, da das Token ungültig ist", "Unverified recovery email:": "Nicht überprüfte Wiederherstellungs-E-Mail:", - "Please set a recovery email address.": "Bitte geben Sie eine Wiederherstellungs-E-Mail-Adresse an." + "Please set a recovery email address.": "Bitte geben Sie eine Wiederherstellungs-E-Mail-Adresse an.", + "The domain of this email address is blacklisted. Please provide another recovery address.": "Die Domäne dieser E-Mailadresse ist auf der Sperrliste. Bitte geben Sie eine andere E-Mailadresse an." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de.json b/l10n/de.json index ed800ff806259592d235caef63284e53be64a859..d7eed7378b6535e358b6be042d0a70cd1f1f3245 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -29,6 +29,7 @@ "Could not verify recovery email because the token is expired": "Wiederherstellungs-E-Mail konnte nicht überprüft werden, da das Token abgelaufen ist", "Could not verify recovery email because the token is invalid": "Wiederherstellungs-E-Mail konnte nicht überprüft werden, da das Token ungültig ist", "Unverified recovery email:": "Nicht überprüfte Wiederherstellungs-E-Mail:", - "Please set a recovery email address.": "Bitte geben Sie eine Wiederherstellungs-E-Mail-Adresse an." + "Please set a recovery email address.": "Bitte geben Sie eine Wiederherstellungs-E-Mail-Adresse an.", + "The domain of this email address is blacklisted. Please provide another recovery address.": "Die Domäne dieser E-Mailadresse ist auf der Sperrliste. Bitte geben Sie eine andere E-Mailadresse an." },"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 5caf16daa9ab11adcebdae0121152b862afffceb..a1231789fd9834466a4536c30f5412e9c33bf299 100644 --- a/l10n/de_DE.js +++ b/l10n/de_DE.js @@ -31,6 +31,7 @@ OC.L10N.register( "Could not verify recovery email because the token is expired": "Wiederherstellungs-E-Mail konnte nicht überprüft werden, da das Token abgelaufen ist", "Could not verify recovery email because the token is invalid": "Wiederherstellungs-E-Mail konnte nicht überprüft werden, da das Token ungültig ist", "Unverified recovery email:": "Nicht überprüfte Wiederherstellungs-E-Mail:", - "Please set a recovery email address.": "Bitte geben Sie eine Wiederherstellungs-E-Mail-Adresse an." + "Please set a recovery email address.": "Bitte geben Sie eine Wiederherstellungs-E-Mail-Adresse an.", + "The domain of this email address is blacklisted. Please provide another recovery address.": "Die Domäne dieser E-Mailadresse ist auf der Sperrliste. Bitte geben Sie eine andere E-Mailadresse an." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de_DE.json b/l10n/de_DE.json index ed800ff806259592d235caef63284e53be64a859..d7eed7378b6535e358b6be042d0a70cd1f1f3245 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -29,6 +29,7 @@ "Could not verify recovery email because the token is expired": "Wiederherstellungs-E-Mail konnte nicht überprüft werden, da das Token abgelaufen ist", "Could not verify recovery email because the token is invalid": "Wiederherstellungs-E-Mail konnte nicht überprüft werden, da das Token ungültig ist", "Unverified recovery email:": "Nicht überprüfte Wiederherstellungs-E-Mail:", - "Please set a recovery email address.": "Bitte geben Sie eine Wiederherstellungs-E-Mail-Adresse an." + "Please set a recovery email address.": "Bitte geben Sie eine Wiederherstellungs-E-Mail-Adresse an.", + "The domain of this email address is blacklisted. Please provide another recovery address.": "Die Domäne dieser E-Mailadresse ist auf der Sperrliste. Bitte geben Sie eine andere E-Mailadresse an." },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/en.js b/l10n/en.js index 5e9593542d275463f743ea55d08819607ee4f4fc..3b7fc65536152a37b37773347c7ce5d9e1827c53 100644 --- a/l10n/en.js +++ b/l10n/en.js @@ -28,6 +28,7 @@ OC.L10N.register( "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.", "Please verify your recovery email address to fully enjoy your murena.io account.": "Please verify your recovery email address to fully enjoy your murena.io account.", "VERIFY RECOVERY EMAIL NOW": "VERIFY RECOVERY EMAIL NOW", - "Please set a recovery email address.": "Please set a recovery email address." + "Please set a recovery email address.": "Please set a recovery email address.", + "The domain of this email address is blacklisted. Please provide another recovery address.": "The domain of this email address is blacklisted. Please provide another recovery address." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/en.json b/l10n/en.json index ffa54b30601fde2b1b7afe12e7a4d05d106bf3fb..46c1dbfb6f8a7f09915acc47927a71ab52d41a48 100644 --- a/l10n/en.json +++ b/l10n/en.json @@ -29,7 +29,8 @@ "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.", "Please verify your recovery email address to fully enjoy your murena.io account.": "Please verify your recovery email address to fully enjoy your murena.io account.", "VERIFY RECOVERY EMAIL NOW": "VERIFY RECOVERY EMAIL NOW", - "Please set a recovery email address.": "Please set a recovery email address." + "Please set a recovery email address.": "Please set a recovery email address.", + "The domain of this email address is blacklisted. Please provide another recovery address.": "The domain of this email address is blacklisted. Please provide another recovery address." }, "pluralForm": "nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/l10n/es.js b/l10n/es.js index 246c55b1198225d233a1785b7d1bcc08aa58ac2d..1d0f7c118123682d3339d3e31db3a6ab5a2266bd 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -31,6 +31,7 @@ OC.L10N.register( "Could not verify recovery email because the token is expired": "No se pudo 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 pudo 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:", - "Please set a recovery email address.": "Por favor configura un correo electrónico para recuperación." + "Please set a recovery email address.": "Por favor configura un correo electrónico para recuperación.", + "The domain of this email address is blacklisted. Please provide another recovery address.": "El dominio de esta dirección de correo electrónico está en lista negra. Por favor, proporciona otra dirección de recuperación." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/es.json b/l10n/es.json index ac9592f6286cbd123c61a9ebd210869b33452e39..a235c024d21d92155e01ea2f3c63f26bd70e9056 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -29,7 +29,8 @@ "Could not verify recovery email because the token is expired": "No se pudo 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 pudo 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:", - "Please set a recovery email address.": "Por favor configura un correo electrónico para recuperación." + "Please set a recovery email address.": "Por favor configura un correo electrónico para recuperación.", + "The domain of this email address is blacklisted. Please provide another recovery address.": "El dominio de esta dirección de correo electrónico está en lista negra. Por favor, proporciona otra dirección 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 735fd61b3918b5add0bf36d1a7a20967784e96cd..44f37aec0b2aef4de1f86bc91424fe04fb634df4 100644 --- a/l10n/fr.js +++ b/l10n/fr.js @@ -31,6 +31,7 @@ OC.L10N.register( "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:": "E-mail de récupération non vérifié :", - "Please set a recovery email address.": "Merci d'ajouter une adresse e-mail de récupération." + "Please set a recovery email address.": "Merci d'ajouter une adresse e-mail de récupération.", + "The domain of this email address is blacklisted. Please provide another recovery address.": "Le domain de cette adresse e-mail est sur liste noire. Merci de bien vouloir fournir une autre adresse de récupération." }, "nplurals=2; plural=n > 1;"); diff --git a/l10n/fr.json b/l10n/fr.json index 540eb81eca08d33d00137a6e104fed6fb9abe721..c49d475a9ce895df3258361770d63c9814a8d7a1 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -29,7 +29,8 @@ "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:": "E-mail de récupération non vérifié :", - "Please set a recovery email address.": "Merci d'ajouter une adresse e-mail de récupération." + "Please set a recovery email address.": "Merci d'ajouter une adresse e-mail de récupération.", + "The domain of this email address is blacklisted. Please provide another recovery address.": "Le domain de cette adresse e-mail est sur liste noire. Merci de bien vouloir fournir une autre adresse 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 e052cbb360585643827cee91df84e9338cfbd269..eaa598a4c9591aba9bb2000eaba3163f034222e3 100644 --- a/l10n/it.js +++ b/l10n/it.js @@ -31,6 +31,7 @@ OC.L10N.register( "Could not verify recovery email because the token is expired": "Impossibile verificare l'e-mail di recovery perché il token è scaduto", "Could not verify recovery email because the token is invalid": "Impossibile verificare l'e-mail di recovery perché il token non è valido", "Unverified recovery email:": "E-mail di recovery non verificata:", - "Please set a recovery email address.": "Imposta un indirizzo e-mail di recovery." + "Please set a recovery email address.": "Imposta un indirizzo e-mail di recovery.", + "The domain of this email address is blacklisted. Please provide another recovery address.": "Il dominio cui appartiene questo indirizzo e-mail è contenuto in una black list. Inserisci un indirizzo di recovery differente." }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/it.json b/l10n/it.json index 1f25113121a99467f00476592a068970232436dd..653ed50c54f09bc74ee5432397f829766ac133c4 100644 --- a/l10n/it.json +++ b/l10n/it.json @@ -29,6 +29,7 @@ "Could not verify recovery email because the token is expired": "Impossibile verificare l'e-mail di recovery perché il token è scaduto", "Could not verify recovery email because the token is invalid": "Impossibile verificare l'e-mail di recovery perché il token non è valido", "Unverified recovery email:": "E-mail di recovery non verificata:", - "Please set a recovery email address.": "Imposta un indirizzo e-mail di recovery." + "Please set a recovery email address.": "Imposta un indirizzo e-mail di recovery.", + "The domain of this email address is blacklisted. Please provide another recovery address.": "Il dominio cui appartiene questo indirizzo e-mail è contenuto in una black list. Inserisci un indirizzo di recovery differente." },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/lib/Controller/EmailRecoveryApiController.php b/lib/Controller/EmailRecoveryApiController.php index 967645f5e8117b2c46d558b68fca76410ddef66d..f60a18f7895e71cee4672398496746952f552a7f 100644 --- a/lib/Controller/EmailRecoveryApiController.php +++ b/lib/Controller/EmailRecoveryApiController.php @@ -24,12 +24,13 @@ namespace OCA\EmailRecovery\Controller; -use OCP\AppFramework\ApiController; -use OCP\ILogger; -use OCP\AppFramework\Http\Response; -use OCA\EmailRecovery\Service\RecoveryEmailService; +use OCA\EmailRecovery\Exception\BlacklistedEmailException; use OCA\EmailRecovery\Exception\InvalidRecoveryEmailException; use OCA\EmailRecovery\Exception\SameRecoveryEmailAsEmailException; +use OCA\EmailRecovery\Service\RecoveryEmailService; +use OCP\AppFramework\ApiController; +use OCP\AppFramework\Http\Response; +use OCP\ILogger; class EmailRecoveryApiController extends ApiController { /** @var ILogger */ @@ -82,7 +83,7 @@ class EmailRecoveryApiController extends ApiController { } } catch (Exception $e) { $response->setStatus(500); - if ($e instanceof SameRecoveryEmailAsEmailException || $e instanceof InvalidRecoveryEmailException) { + if ($e instanceof SameRecoveryEmailAsEmailException || $e instanceof InvalidRecoveryEmailException || $e instanceof BlacklistedEmailException) { $response->setStatus(400); } $this->logger->error("Error updating recovery email for user $id " . $e->getMessage()); diff --git a/lib/Controller/EmailRecoveryController.php b/lib/Controller/EmailRecoveryController.php index 9a29776d98a7a09674f5542e79985040c6342388..cded6cd55d8d930cb7b4916984f669cb377375e9 100644 --- a/lib/Controller/EmailRecoveryController.php +++ b/lib/Controller/EmailRecoveryController.php @@ -29,6 +29,7 @@ use OCA\EmailRecovery\Exception\InvalidRecoveryEmailException; use OCA\EmailRecovery\Exception\MurenaDomainDisallowedException; use OCA\EmailRecovery\Exception\RecoveryEmailAlreadyFoundException; use OCA\EmailRecovery\Exception\SameRecoveryEmailAsEmailException; +use OCA\EmailRecovery\Exception\BlacklistedEmailException; use OCA\EmailRecovery\Service\RecoveryEmailService; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\JSONResponse; @@ -183,6 +184,10 @@ class EmailRecoveryController extends Controller { $response->setStatus(400); $response->setData(['message' => $this->l->t('You cannot set an email address with a Murena domain as recovery email address.')]); } + if ($e instanceof BlacklistedEmailException) { + $response->setStatus(400); + $response->setData(['message' => $this->l->t('The domain of this email address is blacklisted. Please provide another recovery address.')]); + } } } } diff --git a/lib/Exception/BlacklistedEmailException.php b/lib/Exception/BlacklistedEmailException.php new file mode 100644 index 0000000000000000000000000000000000000000..a6d22356f8948108e027ddd98cff7ab5e5ced788 --- /dev/null +++ b/lib/Exception/BlacklistedEmailException.php @@ -0,0 +1,11 @@ +logger->info("User ID $username's requested recovery email address is disallowed."); throw new MurenaDomainDisallowedException(); } + if ($this->isBlacklistedEmail($recoveryEmail)) { + $this->logger->info("User ID $username's requested recovery email address domain is blacklisted. Please provide another recovery address."); + throw new BlacklistedEmailException(); + } } return true; } @@ -214,4 +219,24 @@ class RecoveryEmailService { $this->deleteUnverifiedRecoveryEmail($userId); } } + /** + * Check if an email domain is blacklisted against a JSON list of disposable email domains. + * + * @param string $email The email address to check. + * @return bool True if the email domain is blacklisted, false otherwise. + */ + public function isBlacklistedEmail(string $email): bool { + // Get the blacklisted domains from configuration + $blacklistedDomainsInJson = $this->config->getAppValue('ecloud-accounts', 'blacklisted_domains'); + $blacklistedDomains = json_decode($blacklistedDomainsInJson, true); + + // Split the email address into parts using explode + $emailParts = explode('@', $email); + + // Extract the domain part + $emailDomain = strtolower(end($emailParts)); + + // Check if the email domain is in the blacklisted domains array + return in_array($emailDomain, $blacklistedDomains); + } }