Exception Filter " throw new UnauthorizedException " refresh my page

Viewed 38

When I try to log in and my API returns my login page refresh.

throw new UnauthorizedException('Incorrect email or password');

but when I try with another error exception like :

throw new ForbiddenException,  throw new NotFoundException

my function

async validate(req, email: string, password: string): Promise<any> {
const user = await this.authService.validateUser(email, password);
if (!user) {
  throw new UnauthorizedException('Incorrect email or password');
}
if (!user.verified) {
  console.log('user not verified');
  // Vérifier que le lien n'a pas expiré, sinon supprimer le compte
  const confirmationToken =
    await this.authService.findAndSendConfirmationTokenOrDeleteUser(
      user,
      req.headers.origin,
    );
  if (confirmationToken) {
    throw new ForbiddenException(
      "Veuillez cliquer sur le lien d'activation envoyé par email pour accéder à votre compte",
    );
  } else {
    throw new UnauthorizedException('Incorrect email or password');
  }
}
return user;

}

I don't have this problem, the problem is not on the front-end (the submit prevent default is works)
If anyone can help me please <3
Thanks ;)

Fix: It was axios redirecting if error 401.

0 Answers
Related