mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 19:30:57 +00:00
18 lines
599 B
TypeScript
18 lines
599 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(config: ConfigService) {
|
|
super({
|
|
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
secretOrKey: config.get('JWT_SECRET'),
|
|
});
|
|
}
|
|
async validate(payload: any) {
|
|
return { userId: payload.sub, email: payload.email, role: payload.role, passengerId: payload.passengerId };
|
|
}
|
|
}
|