title: NestJS - How to use RoleGuard with JWT?
body: <p>Currently, I've managed to use AuthGuard with JWT authentication, but I'm not managing to get the <code>user</code> on <code>Roles</code>.</p>
  
  <p>I've tried to follow the cats <a href="https://github.com/nestjs/nest/blob/master/sample/01-cats-app/src/common/guards/roles.guard.ts#L14" rel="nofollow noreferrer">example</a>, but I never get the <code>user</code> object defined, you can see on line 14.</p>
  
  <p>This is my code:</p>
  
  <pre><code>// auth.controller.ts
  @Controller('auth')
  @UseGuards(RolesGuard)
  export class AuthController {
    constructor(private readonly authService: AuthService) {}
  
    @Get('token')
    async createToken(): Promise&lt;any&gt; {
      return await this.authService.createToken();
    }
  
    @Post()
    @UseGuards(AuthGuard())
    @Roles('admin')
    findAll() {
      // this route is restricted by AuthGuard
      // JWT strategy
      return 'Super important info';
    }
  }
  
  
  // auth.module.ts
  @Module({
    imports: [
      SharedModule,
      PassportModule.register({ defaultStrategy: 'jwt' }),
      JwtModule.registerAsync({
        imports: [SharedModule],
        useFactory: async (configService: ConfigService) =&gt; ({
          secretOrPrivateKey: configService.get('SECRET_KEY'),
          signOptions: {
            expiresIn: configService.get('SECRET_KEY_EXPIRES'),
          },
        }),
        inject: [ConfigService],
      }),
    ],
    controllers: [AuthController],
    providers: [
      AuthService,
      JwtStrategy,
    ],
  })
  export class AuthModule {}
  </code></pre>
  
  <p>All the rest is exactly as the example on the repository. Any idea how to be able to get the <code>users</code> defined?</p>