Closed AarNtyon closed 2 months ago
Thank you for taking the time to submit your report! From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the # 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.
Is there an existing issue for this?
Current behavior
` @Module({ imports: [ PassportModule.register({ property: 'account', }), ] })
@Injectable() export class LocalStrategy extends PassportStrategy(Strategy, 'local') { constructor( private readonly authService: AuthService, @Optional() options: AuthModuleOptions, ) { const params: IStrategyOptions = { usernameField: 'username', passwordField: 'password', }; super({ ...params, ...options }); } async validate(username: string, password: string): Promise {
return this.authService.validateUserLocalStrategy({
username,
password,
});
}
}
@Controller('test') export class TestController { @Post('login') @ApiOperation({ summary: 'test' }) @UseGuards(LocalGuard) getAllUser(@Body() _: CreateUserDto, @Req() req: Request & { account: any; user: any }) { console.log('req.account', req.account); console.log('req.user', req.user); } }
`
Minimum reproduction code
https://github.com/nestjs/passport/issues/658
Steps to reproduce
No response
Expected behavior
We want passport to write "user" information in "authentication" property of request object instead of "user" property of request. We import passportModule with register and set option "property" to "account"
Package version
"@nestjs/passport": "^10.0.3",
Passport version
No response
NestJS version
No response
Node.js version
No response
In which operating systems have you tested?
Other
No response