From 97da38e31d2d0353c6868f5f84b727b2053b6a5b Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:06:44 -0600 Subject: [PATCH] Add user active check and improve error handling in auth services --- libs/common/src/auth/services/auth.service.ts | 3 +++ src/auth/services/user-auth.service.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/common/src/auth/services/auth.service.ts b/libs/common/src/auth/services/auth.service.ts index 7f4f03a..95d592e 100644 --- a/libs/common/src/auth/services/auth.service.ts +++ b/libs/common/src/auth/services/auth.service.ts @@ -45,6 +45,9 @@ export class AuthService { if (!user.isUserVerified) { throw new BadRequestException('User is not verified'); } + if (!user.isActive) { + throw new BadRequestException('User is not active'); + } if (user) { const passwordMatch = this.helperHashService.bcryptCompare( pass, diff --git a/src/auth/services/user-auth.service.ts b/src/auth/services/user-auth.service.ts index 89eda76..afdf6d2 100644 --- a/src/auth/services/user-auth.service.ts +++ b/src/auth/services/user-auth.service.ts @@ -151,7 +151,7 @@ export class UserAuthService { }); return res; } catch (error) { - throw new BadRequestException('Invalid credentials'); + throw new BadRequestException(error.message || 'Invalid credentials'); } }