Skip to content

Commit

Permalink
handle user not found (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitiwat-owen authored Nov 14, 2023
1 parent 393a634 commit bfd4170
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,12 @@ export class AuthService implements AuthServiceController {
request.accessToken,
) as JwtPayload;
const user = await this.userRepo.findUserById(credential.sub);
if (!user) {
throw new RpcException({
code: status.NOT_FOUND,
message: 'Not found user',
});
}

const isPasswordMatch = await bcrypt.compare(
request.password,
Expand Down Expand Up @@ -456,6 +462,13 @@ export class AuthService implements AuthServiceController {
message: 'user not found',
});
}
if (user.facebookID || user.googleID) {
throw new RpcException({
code: status.NOT_FOUND,
message: 'user not found',
});
}

// gen token
const userToken = (await this.getTokens(user.id, user.role)).accessToken;
const linkToResetPassword =
Expand Down

0 comments on commit bfd4170

Please sign in to comment.