From f97b02fdfaa7d73a261b0f4f503155267cc36edb Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Wed, 5 Feb 2025 08:09:21 -0600 Subject: [PATCH] Fix user sign-up logic to correctly handle inactive users --- src/auth/services/user-auth.service.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/auth/services/user-auth.service.ts b/src/auth/services/user-auth.service.ts index 6e7780c..c3939c2 100644 --- a/src/auth/services/user-auth.service.ts +++ b/src/auth/services/user-auth.service.ts @@ -36,10 +36,11 @@ export class UserAuthService { async signUp(userSignUpDto: UserSignUpDto): Promise { const findUser = await this.findUser(userSignUpDto.email); - if (!findUser.isActive) { - throw new BadRequestException('User is not active'); - } + if (findUser) { + if (!findUser.isActive) { + throw new BadRequestException('User is not active'); + } throw new BadRequestException('User already registered with given email'); } const salt = this.helperHashService.randomSalt(10); // Hash the password using bcrypt