req.session.passport and req.user empty, serializeUser and deserializeUser are never called
You need to call req.login()
in custom callback which will then call serializeUser
and set the user object to the session:
app.post('/login', function (req, res, next) { passport.authenticate('local-login', function (err, user, info) { if (err) { mysend(res, 500, 'Ups. Something broke!'); } else if (info) { mysend(res, 401, 'unauthorized'); } else { req.login(user, function(err) { if (err) { mysend(res, 500, 'Ups.'); } else { mysend(res, 200, JSON.stringify(user)); } } } })(req, res, next);});