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

Not able to pass info object from Custom Passport Stategy #89

Closed
vimalraj-a opened this issue Jun 19, 2019 · 1 comment
Closed

Not able to pass info object from Custom Passport Stategy #89

vimalraj-a opened this issue Jun 19, 2019 · 1 comment

Comments

@vimalraj-a
Copy link

vimalraj-a commented Jun 19, 2019

Since validate function is being considered as promise don't send callback function of passport. Because callback function is called from after validate function completed Ref: passport.strategy.ts.

Moreover, I don't understand how to pass info (3rd parameter of callback). Since its being used for authInfo field of request object in auth.guard.ts file.

const done = params[params.length - 1];
try {
const validateResult = await this.validate(...params);
if (Array.isArray(validateResult)) {
done(null, ...validateResult);
} else {
done(null, validateResult);
}
} catch (err) {
done(err, null);
}

passport.authenticate(type, options, (err, user, info) => {
try {
request.authInfo = info;
return resolve(callback(err, user, info));
} catch (err) {
reject(err);
}
})(request, response, err => (err ? reject(err) : resolve))

@vimalraj-a vimalraj-a changed the title Don't pass callback function if validate function handled by Promise Not able to pass info object from Custom Passport Stategy Jun 19, 2019
@csidell-earny
Copy link

csidell-earny commented Jul 11, 2019

When you return from the validate function return [ {user}, {info} ].

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

3 participants