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.74k stars 498 forks source link

Allow extra parameters to local verify call #128

Open MubashirSakhi opened 8 years ago

MubashirSakhi commented 8 years ago

i have a model with properties email, password, contact and name. What should i do? do i just use email and password to authenticate/ if yes then what about other paramters?

abou7mied commented 8 years ago

http://stackoverflow.com/a/11784742/1431224

There's a passReqToCallback option that you can enable, like so:

passport.use(new LocalStrategy(
  {usernameField: 'email', passReqToCallback: true},
  function(req, email, password, done) {
    // now you can check req.body.foo
  }
));

When, set req becomes the first argument to the verify callback, and you can inspect it as you wish.