【问题标题】:Combine multiple auths with passport, express & NodeJS将多个身份验证与护照、快递和 NodeJS 相结合
【发布时间】:2015-01-08 03:17:59
【问题描述】:

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

知道我可以/应该怎么做吗?

【问题讨论】:

    标签: node.js passport.js


    【解决方案1】:

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

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

    【讨论】:

    • 你知道我该如何处理这样一种情况:用户先用他们的社交网络注册,然后退出,然后用本地帐户登录,然后连接到之前登录的同一个社交网络帐户与。在这种情况下,我只剩下两行,社交网络登录没有登录到本地帐户,但本地帐户显示它已连接到该社交媒体平台。
    猜你喜欢
    • 2016-01-19
    • 1970-01-01
    • 2013-06-28
    • 2016-03-26
    • 1970-01-01
    • 1970-01-01
    • 2021-06-14
    • 1970-01-01
    • 2016-02-29
    相关资源
    最近更新 更多