Answer the question
In order to leave comments, you need to log in
Why do we need serializeUser and deserializeUser, as well as process.nextTick?
I use passport-vkontakte for authorization in the application via VK.
Two questions:
1) Why do we need serializeUser and deserializeUser
2) Why do we need processNexttick
About the first point:
// Passport session setup.
// To support persistent login sessions, Passport needs to be able to
// serialize users into and deserialize users out of the session. Typically,
// this will be as simple as storing the user ID when serializing, and finding
// the user by ID when deserializing. However, since this example does not
// have a database of user records, the complete VK profile is serialized
// and deserialized.
passport.serializeUser(function(user, done) {
done(null, user);
});
passport.deserializeUser(function(obj, done) {
done(null, obj);
});
passport.use(new VkStrategy(
{
clientID: VK_APP_ID,
clientSecret: VK_APP_SECRET,
callbackURL: "http://localhost:3000/auth/vk/callback",
scope: ['email'],
profileFields: ['email'],
},
function verify(accessToken, refreshToken, params, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
return done(null, profile);
});
}
));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question