最佳答案
你如何向外行解释Passport的序列化和反序列化方法的工作流程?
在调用passport.serializeUser
之后,user.id
去了哪里?< br >
passport.deserializeUser
,它在工作流中的位置是什么?
// used to serialize the user for the session
passport.serializeUser(function(user, done) {
done(null, user.id);
// where is this user.id going? Are we supposed to access this anywhere?
});
// used to deserialize the user
passport.deserializeUser(function(id, done) {
User.findById(id, function(err, user) {
done(err, user);
});
});
I'm still trying to wrap my head around it. I have a complete working app and am not running into errors of any kind.
I just wanted to understand what exactly is happening here?
Any help is appreciated.