adding optional auth to guard

This commit is contained in:
2024-09-24 08:47:52 -05:00
parent fcffd65d33
commit 72683c9ae2

View File

@@ -15,8 +15,11 @@ export class AuthGuard extends PassportAuthGuard('azure-ad') implements CanActiv
'isPublic', 'isPublic',
context.getHandler() context.getHandler()
); );
const req = context.switchToHttp().getRequest();
const authHeader = req.headers.authorization;
const token = authHeader && authHeader.split(' ')[1];
if (isPublic) { if (isPublic && !token) {
return true; return true;
} }