refactor: replace disposable email validation logic with Utopia Emails library

- Introduced the EmailNotDisposable validator from the Utopia Emails library for improved disposable email validation in the account API.
- Removed the deprecated disposable emails configuration loading from the config files to streamline the codebase.
This commit is contained in:
Eldad Fux
2025-10-19 22:01:27 +01:00
parent 18a66bae4e
commit 6c6c71484d
2 changed files with 5 additions and 7 deletions
+5 -6
View File
@@ -21,6 +21,7 @@ use Appwrite\Event\StatsUsage;
use Appwrite\Extend\Exception;
use Appwrite\Hooks\Hooks;
use Utopia\Emails\Validator\Email;
use Utopia\Emails\Validator\EmailNotDisposable;
use Appwrite\Network\Validator\Redirect;
use Appwrite\OpenSSL\OpenSSL;
use Appwrite\SDK\AuthType;
@@ -371,9 +372,8 @@ App::post('/v1/account')
}
if (($plan['supportsDisposableEmailValidation'] ?? false) && ($project->getAttribute('auths', [])['disposableEmails'] ?? false)) {
$disposableEmails = Config::getParam('disposableEmails', []);
$emailDomain = substr(strrchr($email, "@"), 1);
if (isset($disposableEmails[$emailDomain])) {
$emailNotDisposableValidator = new EmailNotDisposable();
if (!$emailNotDisposableValidator->isValid($email)) {
throw new Exception(Exception::USER_EMAIL_DISPOSABLE);
}
}
@@ -3079,9 +3079,8 @@ App::patch('/v1/account/email')
}
if (($plan['supportsDisposableEmailValidation'] ?? false) && ($project->getAttribute('auths', [])['disposableEmails'] ?? false)) {
$disposableEmails = Config::getParam('disposableEmails', []);
$emailDomain = substr(strrchr($email, "@"), 1);
if (isset($disposableEmails[$emailDomain])) {
$emailNotDisposableValidator = new EmailNotDisposable();
if (!$emailNotDisposableValidator->isValid($email)) {
throw new Exception(Exception::USER_EMAIL_DISPOSABLE);
}
}
-1
View File
@@ -40,4 +40,3 @@ Config::load('storage-outputs', __DIR__ . '/../config/storage/outputs.php');
Config::load('specifications', __DIR__ . '/../config/specifications.php');
Config::load('templates-function', __DIR__ . '/../config/templates/function.php');
Config::load('templates-site', __DIR__ . '/../config/templates/site.php');
Config::load('disposableEmails', __DIR__ . '/../config/domains/disposable-emails.php'); // (eldad) following cloud camelCase format. Wish we could be consistent with the rest of the codebase.