jaredhanson / passport-local

Username and password authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-local/?utm_source=github&utm_medium=referral&utm_campaign=passport-local&utm_content=about
MIT License
2.73k stars 497 forks source link

Give error on Missing Credentials instead of info #156

Open rkt2spc opened 7 years ago

rkt2spc commented 7 years ago

I suggest we return error on Missing Credentials instead of return { message: 'missing credentials' } to info, it feels kinda odd

passport.authenticate('local', (err, user) => {
  if (err typeof require('passport-local/errors/MissingCredentials'))
  ...
})

Instead of

passport.authenticate('local', (err, user, info) => {
  if (!err && !user && info && info.message == 'Missing Credentials')
  ...
})
Hum4n01d commented 6 years ago

This is a pretty annoying error to debug, it would be helpful if an error was thrown, but at the same time, there's it isn't really an error; if somebody sends a malformed request, the problem is on their side, not the server's