canina/backend/src/auth/jwt-auth.guard.ts
parsa aghaei 62bd8811fa
All checks were successful
Deploy Canina / deploy (push) Successful in 4m58s
style: apply standard ESLint & Prettier formatting across backend
2026-07-29 15:41:53 +03:30

15 lines
419 B
TypeScript

import { Injectable, UnauthorizedException } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
@Injectable()
export class JwtAuthGuard extends AuthGuard('jwt') {
handleRequest(err: any, user: any, info: any) {
if (err || !user) {
throw (
err || new UnauthorizedException('لطفا ابتدا وارد حساب کاربری خود شوید')
);
}
return user;
}
}