Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: authInfo #23

Closed
Zclhlmgqzc opened this issue Nov 9, 2018 · 1 comment
Closed

Bug: authInfo #23

Zclhlmgqzc opened this issue Nov 9, 2018 · 1 comment

Comments

@Zclhlmgqzc
Copy link

Zclhlmgqzc commented Nov 9, 2018

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

export class JwtStrategy extends PassportStrategy(Strategy) {
...
async validate(payload: JwtPayload, done: Function) {
if (!payload) {
return done(new UnauthorizedException(), false)
}
done(null, payload, 'xxxxxxxxx')
}
}

request:
{
...
authInfo: undefined,
user: { id: 123, username: 'admin', iat: 1541730420, exp: 1541734020 } }
}

@nestjs/passport/dist/auth.guard.js

const createPassportContext = (request, response) => (type, options, callback) => new Promise((resolve, reject) => passport.authenticate(type, options, (err, user, info) => {
try {
request.authInfo = info;
console.log(request.authInfo:${request.authInfo})
...

it will be executed twice:

request.authInfo:xxxxxxxxx
request.authInfo:undefined

Expected behavior

{
...
authInfo: 'xxxxxxxxx',
user: { id: 123, username: 'admin', iat: 1541730420, exp: 1541734020 } }
}

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: 5.4.0

 
For Tooling issues:
- Node version: 8.12.0 
- Platform:  Windows 

Others:

@kamilmysliwiec
Copy link
Member

Please, use StackOverflow for such questions OR provide a sample repository which reproduces your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants