From cbc8b2ca0dcb29aa4a61ba04d41b378b0aa4201c Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 26 Nov 2025 11:02:00 +0000 Subject: [PATCH] Fix: validator not working --- app/controllers/api/users.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index c78a148e14..dcc69e5131 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -115,9 +115,10 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor $emailCanonical = null; } $hashedPassword = null; - + + $isHashed = !$hash instanceof Plaintext; if (!empty($password)) { - if ($hash instanceof Plaintext) { // Password was never hashed, hash it with the default hash + if (!$isHashed) { // Password was never hashed, hash it with the default hash $defaultHash = new ProofsPassword(); $hashedPassword = $defaultHash->hash($password); $hash = $defaultHash->getHash(); @@ -159,7 +160,7 @@ function createUser(Hash $hash, string $userId, ?string $email, ?string $passwor 'emailIsFree' => $emailCanonical?->isFree(), ]); - if ($hash instanceof Plaintext) { + if (!$isHashed) { $hooks->trigger('passwordValidator', [$dbForProject, $project, $plaintextPassword, &$user, true]); }