最近做一些Node的上手练习,然后打算做一个用户认证,看到一些资料推荐passport-local-mongoose,尝试的做了一下Demo,能跑起来,本来打算根据文档给的方法,自定义一下错误,但是发现不行,我的代码如下
var options = {
UserExistsError :'用户名已存在!'
};
Account.plugin(passportLocalMongoose,options);
module.exports = mongoose.model('Account', Account);
但是实际情况中
报错仍然如上图所示,不知道有没有人用户passport-local-mongoose这款插件,指导一下错误在哪
迷茫2017-04-17 13:12:16
Solved. I checked the source code and found that there is a problem with the existing tutorials on the Internet. It should be
var options = {errorMessages:
{UserExistsError :'用户名已存在!'}
};