Example of non-modified passport app here.
For example, we got this:
var userSchema = mongoose.Schema({
local: {
email: String,
password: String
}
});
And we need to do this:
var userSchema = mongoose.Schema({
local: {
id: String,
user: {
email: String,
password: String
}
}
});
After I did those changes, I signed up, then tried to sign in, but got this error:
node_modules\bcrypt-nodejs\bCrypt.js:642
throw "Incorrect arguments";
All entries like local.email
was renamed into local.user.email
in the files below:
Based on your error, there is a problem, where you use bcrypt
module and it is used just twice in the linked article:
// generating a hash
userSchema.methods.generateHash = function(password) {
return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
};
// checking if password is valid
userSchema.methods.validPassword = function(password) {
return bcrypt.compareSync(password, this.local.password);
};
The first one in not connected to your user schema, so I think the problem is inte second function. Did you change the variables there?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.