File tree Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -77,5 +77,6 @@ const providers: Provider[] = [
7777 ] ,
7878 providers,
7979 controllers : [ GoogleAuthController ] ,
80+ exports : [ AuthenticationHelper ] ,
8081} )
8182export class UserAuthModule { }
Original file line number Diff line number Diff line change 1- import { NestMiddleware } from '@nestjs/common' ;
2- import { NextFunction , Request , Response } from 'express' ;
3-
4- import { ExecutionManager } from '../util/execution.manager' ;
1+ import { Injectable , NestMiddleware } from '@nestjs/common' ;
2+ import { Request , Response , NextFunction } from 'express' ;
53import { AuthenticationHelper } from '../authentication/authentication.helper' ;
4+ import { ExecutionManager } from '../util/execution.manager' ;
65
6+ @Injectable ( )
77export class ExecutionContextBinder implements NestMiddleware {
88 constructor ( private readonly auth : AuthenticationHelper ) { }
99 async use ( req : Request , res : Response , next : NextFunction ) {
1010 ExecutionManager . runWithContext ( async ( ) => {
11- const token = req . headers . authorization ?. split ( ' ' ) [ 1 ] ;
12- if ( token ) {
13- const user = this . auth . validateAuthToken ( token ) ;
14- ExecutionManager . setTenantId ( user . tenantId ) ;
11+ try {
12+ const token = req . headers . authorization ?. split ( ' ' ) [ 1 ] ;
13+ if ( token ) {
14+ const user = this . auth . validateAuthToken ( token ) ;
15+ ExecutionManager . setTenantId ( user . tenantId ) ;
16+ }
17+ next ( ) ;
18+ } catch ( error ) {
19+ next ( error ) ;
1520 }
16- next ( ) ;
1721 } ) ;
1822 }
1923}
You can’t perform that action at this time.
0 commit comments