Open syedmkazmi opened 7 years ago
Hello @syedmkazmi , I had the same problem and found the cause. My user model did not have to have a valid password (if users logged in with social accounts) so the problem was at validPassword method of user schema. In order for bcrypt compare to work, you have to have a bcrypt hashed string password.
userSchema.methods.validPassword = function(candidatePassword) {
if(this.password != null) {
return bcrypt.compareSync(candidatePassword, this.password);
} else {
return false;
}
};
You get the gist. Hope it helps.
You are a god @CanGokdere . I overlooked this before moving to production and suddenly the app started crashing and without much information in the log regarding the issue. Thank you so much for saving my butt here!
Im using passport.js (local strategy) to authenticate users but I am getting the following error:
Unhandled "error" event. (Incorrect arguments)
index.js file:
Authentication.js file:
Passport.js File:
I can't seem to figure out what the issue might be. I've tried checking typeof for both email and password and they are indeed Strings. Does anybody know what could be the issue.