每当我尝试使用新用户登录时,都会出现错误:错误:无法将用户序列化为会话。
但是,第二次重试后,我可以登录而不会出现问题。
这是我在“节点”中的护照代码:
passport.use(new FacebookStrategy({
clientID: 1227008554140703,
clientSecret: fbSecret,
// callbackURL: "http://localhost:8080/facebook/callback"
callbackURL: "https://staging-jobdirecto.herokuapp.com/facebook/callback"
},
function(accessToken, refreshToken, profile, done) {
return database.findOrCreateFacebookUser(profile.id, profile.displayName).then((user) => {
done(null, user)
})
}
));
passport.serializeUser(function(user, done) {
done(null, user.id);
});
passport.deserializeUser(function(id, done) {
return database.getFacebookUser(id).then(user => {
done(null, user);
});
});
app.use(passport.initialize());
app.use(passport.session());