File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
backend/gateway-service/src/modules/auth Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 7
7
Query ,
8
8
Res ,
9
9
UseGuards ,
10
+ Headers ,
11
+ BadRequestException
10
12
} from '@nestjs/common' ;
11
13
import { Response } from 'express' ;
12
14
import {
@@ -89,6 +91,21 @@ export class AuthController {
89
91
) ;
90
92
}
91
93
94
+ // Strictly for SSR
95
+ @Public ( )
96
+ @Post ( 'validate-token' )
97
+ @ApiOkResponse ( { description : 'Token is valid' } )
98
+ @ApiBadRequestResponse ( { description : 'Token is invalid' } )
99
+ async validateToken ( @Headers ( 'authorization' ) authHeader : string ) : Promise < boolean > {
100
+ const [ bearer , token ] = authHeader ?. split ( ' ' ) ;
101
+
102
+ if ( ! ( bearer === 'Bearer' ) || ! token ) {
103
+ throw new BadRequestException ( 'Token not provided' ) ;
104
+ }
105
+
106
+ return await firstValueFrom ( this . authClient . send ( { cmd : 'validate-access-token' } , token ) ) ;
107
+ }
108
+
92
109
@Post ( 'logout' )
93
110
@ApiBearerAuth ( 'access-token' )
94
111
@ApiOkResponse ( { description : 'User logged out successfully' } )
You can’t perform that action at this time.
0 commit comments