Chat / backend /src /modules /auth /jwt-auth.guard.ts
kishankrish19's picture
Deploy Stillwave fullstack clean
b0798af
Raw History Blame Contribute Delete
580 Bytes
import {
Injectable,
ExecutionContext,
UnauthorizedException,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
@Injectable()
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;
}
}