2025-10-02 17:03:25 -06:00
|
|
|
import { ExecutionContext, Injectable, ForbiddenException } from '@nestjs/common';
|
2025-09-19 17:15:05 -06:00
|
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
2025-10-02 17:03:25 -06:00
|
|
|
export class JwtAuthGuard extends AuthGuard('jwt') {
|
|
|
|
|
handleRequest(err: any, user: any, info: any, context: ExecutionContext) {
|
|
|
|
|
if (err || !user) {
|
|
|
|
|
throw new ForbiddenException('Acceso denegado: token inválido o ausente');
|
|
|
|
|
}
|
|
|
|
|
return user;
|
|
|
|
|
}
|
|
|
|
|
}
|