Spaces:
Sleeping
Sleeping
Download backend/src/modules/auth/jwt-auth.guard.ts from kishankrish19/Chat: direct link, hf CLI and curl.
- Browser
- Download file 580 Bytes
-
https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/auth/jwt-auth.guard.ts
- Command line
-
hf download hf://spaces/kishankrish19/Chat/backend/src/modules/auth/jwt-auth.guard.ts
-
curl -L -o jwt-auth.guard.ts https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/auth/jwt-auth.guard.ts
580 Bytes
| import { | |
| Injectable, | |
| ExecutionContext, | |
| UnauthorizedException, | |
| } from '@nestjs/common'; | |
| import { AuthGuard } from '@nestjs/passport'; | |
| () | |
| export class JwtAuthGuard extends AuthGuard('jwt') { | |
| canActivate(context: ExecutionContext) { | |
| return super.canActivate(context); | |
| } | |
| handleRequest( | |
| err: any, | |
| user: any, | |
| info?: any, | |
| context?: ExecutionContext, | |
| status?: any, | |
| ) { | |
| if (err || !user) { | |
| throw ( | |
| err || | |
| new UnauthorizedException('Authentication token missing or invalid') | |
| ); | |
| } | |
| return user; | |
| } | |
| } | |