fix hash check

This commit is contained in:
Philipinho
2025-04-09 19:03:27 +01:00
parent 7fe3c5f177
commit 58d1855a36
@@ -47,13 +47,18 @@ export class AuthService {
includePassword: true, includePassword: true,
}); });
const errorMessage = 'email or password does not match';
if (!user || user?.deletedAt) {
throw new UnauthorizedException(errorMessage);
}
const isPasswordMatch = await comparePasswordHash( const isPasswordMatch = await comparePasswordHash(
loginDto.password, loginDto.password,
user?.password, user.password,
); );
if (!user || !isPasswordMatch || user.deletedAt) { if (!isPasswordMatch) {
throw new UnauthorizedException('email or password does not match'); throw new UnauthorizedException(errorMessage);
} }
user.lastLoginAt = new Date(); user.lastLoginAt = new Date();