chore: add user get profile and check validity route

This commit is contained in:
mahyargdz
2025-01-22 09:50:03 +03:30
parent 7431dad85f
commit 72b6cb35a0
39 changed files with 874 additions and 127 deletions
@@ -0,0 +1,22 @@
import { Injectable } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { PassportStrategy } from "@nestjs/passport";
import { ExtractJwt, Strategy } from "passport-jwt";
import { JWT_STRATEGY_NAME } from "../../../common/constants";
import { ITokenPayload } from "../interfaces/IToken-payload";
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy, JWT_STRATEGY_NAME) {
constructor(configService: ConfigService) {
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
ignoreExpiration: false,
secretOrKey: configService.getOrThrow<string>("JWT_SECRET_KEY"),
});
}
async validate(payload: ITokenPayload) {
return { id: payload.sub, role: payload.role };
}
}