Please, help to figure out the best way to autologin user with passport.js local in MEAN stack applications by DaftMonk https://github.com/DaftMonk/generator-angular-fullstack
I want to login user right after saving him. The following code doesn't help
passport.authenticate('local', function (err, user, info) {
var error = err || info;
if (error) return res.json(401, error);
if (!user) return res.json(404, {message: 'Something went wrong, please try again.'});
var token = auth.signToken(user._id, user.role);
res.json({token: token});
})(req, res, next)
Thanks!
Are you tried to review signup module? Its login the user automatically after registering.