如何记住用户登录的策略?

How to remember strategy that user was logged in?

我有几种策略来验证我的应用程序(twitter、google 等)我需要记住用户登录的策略。存储它的最佳位置在哪里?

{
    "_id": {
        "$oid": "54d67c318ba5c79205c9ca00"
    },
    "facebook": {
        "id": "344435342",
        "token": "xxx",
        "name": "Erik",
        "email": "erik@google.com"
    },
    "twitter": {
        "id": "253452",
        "token": "xxx",
        "name": "Erik",
        "username": "ekir"
    },
}

User Profile (req.user) 包含一个属性

provider {String}

The provider with which the user authenticated (facebook, twitter, etc.).


根据我们在 the chat room it seems you actually needed the access to profile which is available inside function(accessToken, refreshToken, profile, done) { of the passport authenticate function. You could then persist the profile.provider along with the user data model, or store it a session through the use of a passport custom callback 中的讨论。