mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
25 lines
801 B
TypeScript
25 lines
801 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { PassportStrategy } from '@nestjs/passport';
|
|
import { ExtractJwt, Strategy } from 'passport-jwt';
|
|
import { AuthSigninService } from '../commands/AuthSignin.service';
|
|
import { JwtPayload } from '../Auth.interfaces';
|
|
import { ConfigService } from '@nestjs/config';
|
|
|
|
@Injectable()
|
|
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
|
constructor(
|
|
private readonly authSigninService: AuthSigninService,
|
|
private readonly configService: ConfigService,
|
|
) {
|
|
super({
|
|
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
ignoreExpiration: false,
|
|
secretOrKey: configService.get('jwt.secret'),
|
|
});
|
|
}
|
|
|
|
validate(payload: JwtPayload) {
|
|
return this.authSigninService.verifyPayload(payload);
|
|
}
|
|
}
|