2025-09-12 13:18:11 -04:00
|
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
|
import { PassportStrategy } from '@nestjs/passport';
|
|
|
|
|
import { ExtractJwt, Strategy } from 'passport-jwt';
|
|
|
|
|
import { ConfigService } from '@nestjs/config';
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class JwtStrategy extends PassportStrategy(Strategy) {
|
|
|
|
|
constructor(private configService: ConfigService) {
|
|
|
|
|
super({
|
|
|
|
|
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
|
|
|
ignoreExpiration: false,
|
|
|
|
|
secretOrKey: configService.get('JWT_SECRET')!,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async validate(payload: any) {
|
2025-09-19 17:15:05 -06:00
|
|
|
return { id: payload.id, usuario: payload.usuario };
|
2025-09-12 13:18:11 -04:00
|
|
|
}
|
|
|
|
|
}
|