passport
passport copied to clipboard
Documentation for failWithError option
I've noticed that the failWithError option was added back in 2014 (see #126) and wasn't documented in the function description.
This is especially important for people that want a custom error message without having to implement a custom callback:
app.post('/login',
passport.authenticate('local', { failWithError: true }),
function(req, res, next) {
// Handle success
return res.send({ success: true, message: 'Logged in' })
},
function(err, req, res, next) {
// Handle error
return res.status(401).send({ success: false, message: err })
}
)
+1 just stumbled into this when trying to figure out how to implement custom error messages.
Yup, yup +1 on this as well. Having middleware that executes after responses is a vital pattern. The passport default of killing the middleware chain is kind of a bummer most days.
Duplicate: #364
+1 for this. It took me a long time to figure out that this is already supported. I also agree that the passport middleware should not end the middleware chain by default.
+1 looks like some attempted PRs are stale now, but would love to see this doc change too
This issue is five years old, and I just spent all day trying to sort out why such a fundamental feature was "missing". Please update your docs to let future-folks have an easier time than I.