Browse Source

refactor: invoke jwt strategy guard only if header present

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5572/head
Pranav C 2 years ago
parent
commit
0c88394e48
  1. 13
      packages/nocodb-nest/src/guards/global/global.guard.ts

13
packages/nocodb-nest/src/guards/global/global.guard.ts

@ -13,14 +13,17 @@ export class GlobalGuard extends AuthGuard(['jwt']) {
async canActivate(context: ExecutionContext) { async canActivate(context: ExecutionContext) {
let result; let result;
try {
result = await this.extractBoolVal(super.canActivate(context));
} catch (e) {
console.log(e);
}
const req = context.switchToHttp().getRequest(); const req = context.switchToHttp().getRequest();
if(!req.headers?.['xc-auth']) {
try {
result = await this.extractBoolVal(super.canActivate(context));
} catch (e) {
console.log(e);
}
}
if (result && !req.headers['xc-shared-base-id']) { if (result && !req.headers['xc-shared-base-id']) {
if ( if (
req.path.indexOf('/user/me') === -1 && req.path.indexOf('/user/me') === -1 &&

Loading…
Cancel
Save