FIX: tests

This commit is contained in:
Gabriel Rosa
2023-02-17 09:55:10 -03:00
parent 544d13fac5
commit aa9e0536a7
+5 -2
View File
@@ -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);