Files
backend/libs/common/src/guards/jwt.auth.guard.ts
2024-03-10 12:49:51 +03:00

12 lines
286 B
TypeScript

import { UnauthorizedException } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
export class JwtAuthGuard extends AuthGuard('jwt') {
handleRequest(err, user) {
if (err || !user) {
throw err || new UnauthorizedException();
}
return user;
}
}