Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Password field cannot be empty #180

Open
relativityboy opened this issue Feb 26, 2019 · 0 comments
Open

Bug: Password field cannot be empty #180

relativityboy opened this issue Feb 26, 2019 · 0 comments

Comments

@relativityboy
Copy link

In some cases users may need to have a password that is ``. passport-local fails with the message Missing credentials in this case.
This error is wrong, as the password property is present on `req.body`

A zero length password can be useful in testing, initial signup on a closed network, etc.

Expected behavior

When the 'username' and 'password' properties are present on req.body the validation function should be called, unless those properties are undefined.

Actual behavior

If req.body.$passwordField is `` the validation function is not called.

Steps to reproduce

Instantiate any app and pass a password of zero-length when logging in.

Slightly contrived example.

passport.use(new LocalStrategy(
  {
    usernameField: 'email',
    passwordField: 'password'
  },
  (email, password, done) => {
  console.log('LocalStrategy', email, password)
  if(email !== 'admin') return done(null, false, { message: 'Incorrect username.' })
  if(password !== '') return done(null, false, { message: 'Password should be empty.' })
}))

Environment

  • Operating System:
  • Node version: 10.x
  • passport version: 0.4.0
  • passport-local version: 1.0.0
relativityboy added a commit to relativityboy/passport-local that referenced this issue Feb 26, 2019
relativityboy added a commit to relativityboy/passport-local that referenced this issue Feb 26, 2019
relativityboy added a commit to relativityboy/passport-local that referenced this issue Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant