How can I get the request headers inside passport local strategy? I need a separate database for each entity, using mongodb so I need a way to get the subdomain before authentication in order to determine the database that I should connect to
@Injectable()
export class LocalStrategy extends PassportStrategy(Strategy) {
constructor(private authService: AuthService) {
super({ usernameField: 'email' })
}
async validate(email: string, password: string, headers:Headers): Promise<IUser> {
//** this is what I want to have
//** const subdomain = headers.host.split(".")[0]
const user = await this.authService.validateUser({ email, password ,//** subdomain})
if (!user) {
throw new UnauthorizedException()
}
return user
}
}