我正在尝试将LinkedInStrategy
与现有LocalStrategy
合并(用户已经过身份验证)。
以下是护照文档中的示例:
schema.statics.passportLinkedInStrategy = function(token, tokenSecret, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
// To keep the example simple, the user's LinkedIn profile is returned to
// represent the logged-in user. In a typical application, you would want
// to associate the LinkedIn account with a user record in your database,
// and return that user instead.
return done(null, profile);
});
};
问题是我无法访问req.user
来检查此回调中的现有会话。
关于我如何/应该如何做的任何想法?
答案 0 :(得分:3)
请参阅指南Authorize章节中标题为“验证回叫中的关联”的部分。
您可以设置passReqToCallback
选项,它会将req
作为验证回调的第一个参数传递。