diff --git a/appinfo/info.xml b/appinfo/info.xml
index 39b37f5818768f798fb7d03d736387fb8dffde80..bf39775b75ae0ef44c8dfdb474ea8ea983a7daa1 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -5,7 +5,7 @@
Email Recovery
Email Recovery App
- 6.0.2
+ 6.1.0
agpl
MURENA SAS
EmailRecovery
diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php
index 96a27b38061c39557f0a5d565927aeee4956d08b..455ea00a70c0ef5abcef41f1f6d67c64686013f4 100644
--- a/lib/Service/RecoveryEmailService.php
+++ b/lib/Service/RecoveryEmailService.php
@@ -22,6 +22,7 @@ use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
use OCP\Security\VerificationToken\IVerificationToken;
use OCP\Util;
+use OCA\EcloudAccounts\Service\BlackListService;
class RecoveryEmailService {
private ILogger $logger;
@@ -37,8 +38,9 @@ class RecoveryEmailService {
private CurlService $curl;
private array $apiConfig;
protected const TOKEN_LIFETIME = 60 * 30; // 30 minutes
+ private BlackListService $blackListService;
- public function __construct(string $appName, ILogger $logger, IConfig $config, LDAPConnectionService $LDAPConnectionService, IUserManager $userManager, IMailer $mailer, IFactory $l10nFactory, IURLGenerator $urlGenerator, Defaults $themingDefaults, IVerificationToken $verificationToken, CurlService $curlService) {
+ public function __construct(string $appName, ILogger $logger, IConfig $config, LDAPConnectionService $LDAPConnectionService, IUserManager $userManager, IMailer $mailer, IFactory $l10nFactory, IURLGenerator $urlGenerator, Defaults $themingDefaults, IVerificationToken $verificationToken, CurlService $curlService, BlackListService $blackListService) {
$this->logger = $logger;
$this->config = $config;
$this->appName = $appName;
@@ -50,6 +52,7 @@ class RecoveryEmailService {
$this->themingDefaults = $themingDefaults;
$this->verificationToken = $verificationToken;
$this->curl = $curlService;
+ $this->blackListService = $blackListService;
$commonServiceURL = $this->config->getSystemValue('common_services_url', '');
if (!empty($commonServiceURL)) {
@@ -96,7 +99,7 @@ class RecoveryEmailService {
$this->logger->info("User ID $username's requested recovery email address is disallowed.");
throw new MurenaDomainDisallowedException();
}
- if ($this->isBlacklistedEmail($recoveryEmail)) {
+ if ($this->blackListService->isBlacklistedEmail($recoveryEmail)) {
$this->logger->info("User ID $username's requested recovery email address domain is blacklisted. Please provide another recovery address.");
throw new BlacklistedEmailException();
}
@@ -228,33 +231,6 @@ 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');
- if (empty($blacklistedDomainsInJson)) {
- return false;
- }
- $blacklistedDomains = json_decode($blacklistedDomainsInJson, true);
-
- if (empty($blacklistedDomains)) {
- return false;
- }
- // 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);
- }
-
private function manageEmailRestriction(string $email, string $method, string $url) : void {
$params = [];