fix hash check
This commit is contained in:
parent
7fe3c5f177
commit
58d1855a36
1 changed files with 8 additions and 3 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue