This commit is contained in:
2023-06-12 20:01:07 +02:00
parent edc42e3750
commit 59b4eb582e
43 changed files with 1799 additions and 245 deletions

View File

@@ -0,0 +1,21 @@
import { Inject, Injectable } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport';
import { ExtractJwt, Strategy } from 'passport-jwt';
import { AppSettings } from '../../../settings/app-settings';
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
constructor(
@Inject(AppSettings.name) private readonly appSettings: AppSettings,
) {
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
ignoreExpiration: true,
secretOrKey: appSettings.auth.ACCESS_JWT_SECRET_KEY,
});
}
async validate(payload: any) {
return { userId: payload.userId };
}
}