Tuesday 11 April 2017

Passportjs deserialize and reading from session vs database

If passport deserializes the user on every request to a route that uses passport for authentication, assuming we use the following function which is used in most examples: passport.deserializeUser((id, done) => { User.findById(id, (err, user) => { done(err, user); }); }); In that case why not just read data from req.user for GET requests rather than going to the database for an additional lookup of data that already exists in req.user?Is it because we might use something like redis in the future instead?

Submitted April 11, 2017 at 11:42PM by linasmnew

No comments:

Post a Comment