Use email with Passport-local. Previous help not working
It seems to me you just changed the name of the argument in the LocalStrategy callback to "email". Passport doesn't automagically know that the field is named email though, you have to tell it.
By default, LocalStrategy expects to find credentials in parameters named username and password. If your site prefers to name these fields differently, options are available to change the defaults.
passport.use(new LocalStrategy({ usernameField: 'email', passwordField: 'passwd' }, function(username, password, done) { // ... }));
As an addition for those who cannot get it to work with the above solution (like me), try this instead:
passport.use( new LocalStrategy( { passReqToCallback: true, }, (request, username, password, next) => { User.findOne({ email: username }) ...
Package versions (as of today):passport: "^0.4.1",passport-local: "^1.0.0"
If you are new to NestJs and wondering how to achieve the above. You can pass the config options in the super()
method like this:
super({ usernameField: 'email', passwordField: 'password'})