22 lines
645 B
TypeScript
22 lines
645 B
TypeScript
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<string>('JWT_REFRESH_SECRET'),
|
|
});
|
|
}
|
|
|
|
async validate(payload: any) {
|
|
console.log("payload")
|
|
console.log(payload)
|
|
return { userId: payload.sellerid};
|
|
}
|
|
}
|