As I was going through the documentation for passport, I came across an interesting observation regarding the use of serialize()
and deserialize()
. It seems that done()
is called without being explicitly returned in one scenario.
However, while setting up a new strategy using passport.use()
, the callback function uses return done()
. This made me question whether this is a crucial aspect to grasp or simply a convention followed from the documentation.
If you want to explore this further, you can visit the official documentation at .
Here is a snippet from the docs for your reference:
var passport = require('passport')
, LocalStrategy = require('passport-local').Strategy;
passport.use(new LocalStrategy(
function(username, password, done) {
User.findOne({ username: username }, function (err, user) {
if (err) { return done(err); }
if (!user) {
return done(null, false, { message: 'Incorrect username.' });
}
if (!user.validPassword(password)) {
return done(null, false, { message: 'Incorrect password.' });
}
return done(null, user);
});
}
));