Currently I can access messages set in done(null, user, {message: 'ok'})
inside post request via req.authInfo
like this:
app.post('/reg', passport.authenticate('local-reg', { session: false }), function (req, res) {
console.log(req.authInfo.message); --> 'ok'
});
Which is very useful.
But how can i access message like this done(null, false, {message: 'username taken'})
in the same fashion, as it seems that passing done(null, false)
in passport.authenticate makes it throw 401 unathorised, therefore not forwarding to the route handler itself.
Maybe i misunderstood something?
P.S.: I'm posting through jQuery.post
.