passport.serializeUser(function(user, done){
done(null, user.id);
});
passport.deserializeUser(function(id, done){
User.findById(id, function(err, user){
done(err, user);
});
});
passport.use(new GoogleStrategy({
clientID:process.env.CLIENT_ID,
clientSecret:process.env.CLIENT_SECRET,
callbackURL:"http://localhost:3000/auth/google/secrets",
userProfileURL:"https://www.googleapis.com/oauth2/v3/userinfo"
},
function(accessToken, refreshToken, profile, done){
console.log(profile);
User.findOrCreate({googleId: profile.id}, function(err, user){
return done(err, user);
});
}));
Hi, I am learning web dev authetication and this code snippet is driving me crazy. two questions.
why is "return" introduced at the end of the code(line 22) and why isn't it there in serialize and deserializeUser?
what is the difference between null and err, can they be used interchangeably?