Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function deserializeUserPassport(id, done) {
User.findOne({ _id: id }, (err, userModel) => {
if (err) {
done(err);
} else {
if (!userModel) {
done();
return;
}
done(null, userModel.toJSON());
}
});
}
// let's use User id
passport.serializeUser((user, done) => done(null, user._id));
passport.deserializeUser(deserializeUserPassport);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment