Created
March 28, 2020 10:56
-
-
Save callmephilip/32941ceb2fd967a4ac25e1dac69e8241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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