Passport local strategy done callback does not pass error json message
The message
value you are setting is stored in session and flash. I don't think passport has any option to send json error message. But you can pass a callback in authenticate
method and send message from there:
app.post('/login', function(req, res, next ){ passport.authenticate('local', function(err, user, info) { if (err) { return next(err) } if (!user) { return res.json( { message: info.message }) } res.json(user); })(req, res, next); });