diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 987c146e0..5fa62a373 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -71,7 +71,7 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e : ID::custom($userId); if ($project->getAttribute('auths', [])['personalDataCheck'] ?? false) { - $personalDataValidator = new PersonalData($userId, $email, $name, $phone); + $personalDataValidator = new PersonalData($userId, $email, $name, $phone, false, true); if (!$personalDataValidator->isValid($plaintextPassword)) { throw new Exception(Exception::USER_PASSWORD_PERSONAL_DATA); } diff --git a/src/Appwrite/Auth/Validator/PersonalData.php b/src/Appwrite/Auth/Validator/PersonalData.php index 6e2b4a9bd..8eaae002f 100644 --- a/src/Appwrite/Auth/Validator/PersonalData.php +++ b/src/Appwrite/Auth/Validator/PersonalData.php @@ -12,9 +12,10 @@ class PersonalData extends Password protected ?string $email = null, protected ?string $name = null, protected ?string $phone = null, - protected bool $strict = false + protected bool $strict = false, + protected bool $allowEmpty = false, ) { - parent::__construct(); + parent::__construct($allowEmpty); } /** diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index a189e4630..a74d140e2 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -1731,6 +1731,23 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); + $email = uniqid() . 'user@localhost.test'; + $password = ''; + $name = 'username'; + $userId = ID::unique(); + $response = $this->client->call(Client::METHOD_POST, '/account', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + ]), [ + 'email' => $email, + 'password' => $password, + 'name' => $name, + 'userId' => $userId + ]); + + $this->assertEquals(201, $response['headers']['status-code']); + $email = uniqid() . 'user@localhost.test'; $userId = ID::unique(); $response = $this->client->call(Client::METHOD_POST, '/users', array_merge($this->getHeaders(), [