diff --git a/src/authentication/authentication.guard.ts b/src/authentication/authentication.guard.ts index f97bdfe..7e938b0 100644 --- a/src/authentication/authentication.guard.ts +++ b/src/authentication/authentication.guard.ts @@ -54,11 +54,14 @@ export class AuthenticationGuard >(AUTH_FUNCTION_KEY, [ctx.getClass(), ctx.getHandler()]); const mustBeAuthenticated = authFunctions.length > 0; - if (!mustBeAuthenticated) return true; - const request = ctx.switchToHttp().getRequest(); const accessToken = this.validateToken(request, mustBeAuthenticated); + if (!mustBeAuthenticated) { + // no need to be authenticated + return true; + } + if (!accessToken) { // couldn't load valid token throw new ErrorBuilder(ErrorCodes.AUTH.UNAUTHORIZED);