NestJs - Unable to get user context in RolesGuard

前端 未结 2 1078
你的背包
你的背包 2021-02-13 15:32

I\'m using NestJS as the framework for a client API. Within the framework we are using a pretty standard Passport/JWT auth infrastructure that is working fine. Our AuthGuard i

2条回答
  •  情话喂你
    2021-02-13 16:05

    register RoleGuard at the endpoint level and put it after the AuthGuard then it fires second and I get the user context I am expecting within the guard itself. don't register RoleGuard at module causes it'll be registered first and fire first.

    *.module.ts

    imports: [],
      providers: [{provide: APP_GUARD, useClass: RolesGuard} ,],  // remove guard
      controllers: [],
      exports: [],
    

提交回复
热议问题