Browse Source

fix: set preview user directly

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5444/head
Pranav C 2 years ago
parent
commit
87bf5b073b
  1. 4
      packages/nocodb-nest/src/guards/global/global.guard.ts

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

@ -2,8 +2,8 @@ import { Injectable } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { lastValueFrom, Observable } from 'rxjs';
import { JwtStrategy } from '../../strategies/jwt.strategy';
import extractRolesObj from '../../utils/extractRolesObj';
import type { ExecutionContext } from '@nestjs/common';
import extractRolesObj from '../../utils/extractRolesObj'
@Injectable()
export class GlobalGuard extends AuthGuard(['jwt']) {
@ -27,7 +27,7 @@ export class GlobalGuard extends AuthGuard(['jwt']) {
req.header('xc-preview') &&
['owner', 'creator'].some((role) => req.user.roles?.[role])
) {
return this.authenticate(req,{
return (req.user = {
...req.user,
isAuthorized: true,
roles: extractRolesObj(req.header('xc-preview')),

Loading…
Cancel
Save