passport icon indicating copy to clipboard operation
passport copied to clipboard

Documentation for failWithError option

Open puradox opened this issue 9 years ago • 5 comments
trafficstars

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 })
  }
)

puradox avatar Feb 06 '16 01:02 puradox

+1 just stumbled into this when trying to figure out how to implement custom error messages.

ianstormtaylor avatar Mar 06 '16 07:03 ianstormtaylor

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

Freyert avatar Mar 07 '16 21:03 Freyert

+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.

kgalli avatar Jun 02 '16 12:06 kgalli

+1 looks like some attempted PRs are stale now, but would love to see this doc change too

jwater7 avatar Jan 06 '20 06:01 jwater7

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.

develleoper avatar Jun 25 '21 23:06 develleoper