diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index 7ca523d5f1f0360e5c2b28aa5280a7196b34136b..c1001ec62e2a44e3794f2ca94d6fc8b400a7c167 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -136,17 +136,26 @@ class RecoveryEmailService { $this->logger->info('VerifyMail API Key is not configured.'); } - // Check if it's a popular domain and not custom blacklist, then verify the email - if ($this->domainService->isPopularDomain($recoveryEmail, $l) && !$this->domainService->isDomainInCustomBlacklist($recoveryEmail, $l)) { + if ($this->domainService->isDomainInCustomBlacklist($recoveryEmail, $l)) { + \OC::$server->getLogger()->logger("found in custom disposable domain list"); + //throw new \Exception($l->t('The provided email domain is a disposable domain and cannot be used.')); + throw new BlacklistedEmailException($l->t('The email address is disposable. Please provide another recovery address.')); + } + + // Check if the domain is a popular domain + if ($this->domainService->isPopularDomain($recoveryEmail, $l)) { + // Skip domain verification and directly validate the email + $this->ensureRealTimeRateLimit(self::RATE_LIMIT_EMAIL, 2, $l); + $this->ensureEmailIsValid($recoveryEmail, $username, $apiKey, $l); + } else { + // Verify the domain using the API + $this->ensureRealTimeRateLimit(self::RATE_LIMIT_DOMAIN, 15, $l); + $domain = substr(strrchr($recoveryEmail, "@"), 1); + $this->verifyDomainWithApi($domain, $username, $apiKey, $l); + // If domain verification succeeds, validate the email $this->ensureRealTimeRateLimit(self::RATE_LIMIT_EMAIL, 2, $l); $this->ensureEmailIsValid($recoveryEmail, $username, $apiKey, $l); } - - // Verify the domain using the API - $this->ensureRealTimeRateLimit(self::RATE_LIMIT_DOMAIN, 15, $l); - $domain = substr(strrchr($recoveryEmail, "@"), 1); - $this->verifyDomainWithApi($domain, $username, $apiKey, $l); - return true; } private function getUserEmail(string $username): string { @@ -228,7 +237,7 @@ class RecoveryEmailService { $httpClient = $this->httpClientService->newClient(); // Make the API request $response = $httpClient->get($url, [ - 'timeout' => 5, // Timeout for the API call + 'timeout' => 15, // Timeout for the API call ]); // Process response, handle errors (e.g., disposable email, non-deliverable email) @@ -263,7 +272,7 @@ class RecoveryEmailService { $httpClient = $this->httpClientService->newClient(); // Make the API request $response = $httpClient->get($url, [ - 'timeout' => 5, // Timeout for the API call + 'timeout' => 15, // Timeout for the API call ]); // Process response, handle errors (e.g., disposable email, non-deliverable email)