mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user