From 58d1855a360091ae175c75a97c572da934dd3f21 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Wed, 9 Apr 2025 19:03:27 +0100 Subject: [PATCH] fix hash check --- apps/server/src/core/auth/services/auth.service.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/server/src/core/auth/services/auth.service.ts b/apps/server/src/core/auth/services/auth.service.ts index 19f02230..9c761ef3 100644 --- a/apps/server/src/core/auth/services/auth.service.ts +++ b/apps/server/src/core/auth/services/auth.service.ts @@ -47,13 +47,18 @@ export class AuthService { includePassword: true, }); + const errorMessage = 'email or password does not match'; + if (!user || user?.deletedAt) { + throw new UnauthorizedException(errorMessage); + } + const isPasswordMatch = await comparePasswordHash( loginDto.password, - user?.password, + user.password, ); - if (!user || !isPasswordMatch || user.deletedAt) { - throw new UnauthorizedException('email or password does not match'); + if (!isPasswordMatch) { + throw new UnauthorizedException(errorMessage); } user.lastLoginAt = new Date();