将多个身份证与护照,快递和的NodeJS

时间:2012-12-13 20:41:35

标签: node.js passport.js

我正在尝试将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来检查此回调中的现有会话。

关于我如何/应该如何做的任何想法?

1 个答案:

答案 0 :(得分:3)

请参阅指南Authorize章节中标题为“验证回叫中的关联”的部分。

您可以设置passReqToCallback选项,它会将req作为验证回调的第一个参数传递。