Your authenticateUser callback expects username and password to be passed by passportJS. With {usernameField: 'email'} you’re specifying where to find username.
Do I need to specify that when my veryfing callback looks like this:
const authenticateUser = async (email, password, done) => {
const user = getUserByEmail(email)
if(user === null || user === undefined) {
return done(null, false, {message: 'No user with that email'})
}
try {
if (await bcrypt.compare(password, user.password)) {
return done(null, user)
} else {
return done(null, false, {message: 'Password incorrect'})
}
} catch (e){
return done(e)
}
}
I’m pointing to the email, and password so why I should assign email to usernameField variable if I’m not using it anywhere (I mean this usernameField variable)?