From 312b6e33d1525b27d09f84895178476b6299186d Mon Sep 17 00:00:00 2001 From: ruslan-polutsygan Date: Sat, 1 Oct 2016 23:15:39 +0300 Subject: [PATCH] fix(server:auth:local): sessions fix call "req.login" manually in order to use sessions. because custom callback used with "passport.authenticate" see - http://passportjs.org/docs#custom-callback --- templates/app/server/auth(auth)/local/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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); });