FIX: add authentication to swagger

This commit is contained in:
Gabriel Rosa
2023-02-08 15:23:49 -03:00
parent cdba41dffa
commit 8043635b1c
9 changed files with 621 additions and 45 deletions
+2 -5
View File
@@ -54,14 +54,11 @@ 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);