Actually i need to set a header fater jwt strategy validate, anyone know how do i do that? (bellow is my jwt.strategy.ts)
import { ExecutionContext, ForbiddenException, Injectable, UnauthorizedException } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { PassportStrategy } from "@nestjs/passport";
import { ExtractJwt, Strategy } from "passport-jwt";
import { AuthService } from "../auth.service";
import { jwtConstants } from "../constants";
import { JwtAuthDto } from "src/dtos";
import { HttpArgumentsHost } from "@nestjs/common/interfaces";
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy){
constructor(private authService:AuthService){
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
ignoreExpiration:false,
secretOrKey: jwtConstants.secret
});
}
async validate(payload:JwtAuthDto){
const isValid = await this.authService.validateUserByInformationsInPayload(payload);
//*** I need to set a response header HERE ***//
if (isValid)
return payload;
else
throw new UnauthorizedException();
}
}