File

src/module/auth/strategy/picture.strategy.ts

Index

Methods

Constructor

constructor(authService: AuthService)
Parameters :
Name Type Optional
authService AuthService No

Methods

Async validate
validate(payload: any)
Parameters :
Name Type Optional
payload any No
Returns : {}
import { PassportStrategy } from "@nestjs/passport";
import { ExtractJwt, Strategy } from "passport-jwt";
import { Config } from "../../config/entity/config";
import { Injectable } from "@nestjs/common";
import { AuthService } from "../service/auth.service";

@Injectable()
export class JwtQueryStrategy extends PassportStrategy(Strategy, "jwt-query") {
  constructor(private readonly authService: AuthService) {
    super({
      jwtFromRequest: ExtractJwt.fromUrlQueryParameter("token"),
      secretOrKey: Config.get("JWT_SECRET"),
    });
  }

  async validate(payload: any) {
    return await this.authService.authorize(payload.sub);
  }
}

result-matching ""

    No results matching ""