diff --git a/templates/app/server/auth(auth)/local/index.js b/templates/app/server/auth(auth)/local/index.js index 08ebf69b2..2c978b312 100644 --- a/templates/app/server/auth(auth)/local/index.js +++ b/templates/app/server/auth(auth)/local/index.js @@ -16,8 +16,14 @@ router.post('/', function(req, res, next) { return res.status(404).json({message: 'Something went wrong, please try again.'}); } - var token = signToken(user._id, user.role); - res.json({ token }); + req.login(user, err => { + if(err) { + return next(err); + } + + var token = signToken(user._id, user.role); + return res.json({ token }); + }); })(req, res, next); });