import { ExecutionContext , Injectable } from '@nestjs/common' ; import { Reflector } from '@nestjs/core' ; import { AuthGuard } from '@nestjs/passport' ; import { BYPASS_AUTH_KEY } from './bypass-auth.decorator' ; import { getRequest } from './getRequest' ; @ Injectable ( ) export class IdsAuthGuard extends AuthGuard ( 'jwt' ) { getRequest = getRequest ; constructor ( private readonly reflector ) { super ( ) ; } getAuthenticateOptions ( ) { return { property : 'auth' , } ; } canActivate ( context ) { const bypassAuth = this . reflector . getAllAndOverride < boolean > ( BYPASS_AUTH_KEY , [ context . getHandler ( ) , context . getClass ( ) ] ) ; if ( bypassAuth ) { return true ; } return super . canActivate ( context ) ; } }