From 3d356cbf8c19b41f7e0e66731c8038cf1139b7a1 Mon Sep 17 00:00:00 2001 From: alexmerlin Date: Mon, 30 Sep 2024 14:59:43 +0300 Subject: [PATCH] Issue 484: Show correct message when user tries to register with a deleted account email Signed-off-by: alexmerlin --- src/User/src/Repository/UserRepository.php | 8 +++++--- src/User/src/Service/UserService.php | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/User/src/Repository/UserRepository.php b/src/User/src/Repository/UserRepository.php index 2bf5ebfa..697e3b43 100644 --- a/src/User/src/Repository/UserRepository.php +++ b/src/User/src/Repository/UserRepository.php @@ -13,6 +13,9 @@ use Frontend\User\Entity\UserRememberMe; use Ramsey\Uuid\Uuid; +use function is_string; +use function strlen; + /** * @extends EntityRepository */ @@ -50,9 +53,8 @@ public function exists(string $email = '', ?string $uuid = ''): ?User $qb->select('user') ->from(User::class, 'user') - ->where('user.identity = :email')->setParameter('email', $email) - ->andWhere('user.isDeleted = :isDeleted')->setParameter('isDeleted', User::IS_DELETED_NO); - if (! empty($uuid)) { + ->where('user.identity = :email')->setParameter('email', $email); + if (is_string($uuid) && strlen($uuid) > 0) { $uuid = Uuid::fromString($uuid)->getBytes(); $qb->andWhere('user.uuid != :uuid')->setParameter('uuid', $uuid); } diff --git a/src/User/src/Service/UserService.php b/src/User/src/Service/UserService.php index 2f853f92..b32d79cb 100644 --- a/src/User/src/Service/UserService.php +++ b/src/User/src/Service/UserService.php @@ -250,9 +250,7 @@ public function deleteAvatarFile(string $path): bool public function exists(string $email = '', ?string $uuid = ''): bool { - return ! empty( - $this->userRepository->exists($email, $uuid) - ); + return $this->userRepository->exists($email, $uuid) instanceof User; } /**