15 lines
419 B
TypeScript
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;
|
|
}
|
|
}
|