From 3015f7f10f7df2969a233f98c9ffc1ea903610d8 Mon Sep 17 00:00:00 2001 From: Fabien MEYNARD Date: Mon, 5 Mar 2018 16:15:13 +0100 Subject: [PATCH] Update callback to throw UnauthorizedException This is to avoid inconsistency between not providing a token & providing a bad token --- src/app/homepage/pages/recipes/passport/passport.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/homepage/pages/recipes/passport/passport.component.ts b/src/app/homepage/pages/recipes/passport/passport.component.ts index e6d5ff0751..7b0b0a4940 100644 --- a/src/app/homepage/pages/recipes/passport/passport.component.ts +++ b/src/app/homepage/pages/recipes/passport/passport.component.ts @@ -66,7 +66,7 @@ export class AuthService { return ` import * as passport from 'passport'; import { ExtractJwt, Strategy } from 'passport-jwt'; -import { Component, Inject } from '@nestjs/common'; +import { Component, Inject, UnauthorizedException } from '@nestjs/common'; import { AuthService } from '../auth.service'; @Component() @@ -86,7 +86,7 @@ export class JwtStrategy extends Strategy { public async verify(req, payload, done) { const isValid = await this.authService.validateUser(payload); if (!isValid) { - return done('Unauthorized', false); + return done(new UnauthorizedException(), false); } done(null, payload); }