search

Home  >  Q&A  >  body text

node.js - 关于passport-local-mongoose自定义错误的问题

最近做一些Node的上手练习,然后打算做一个用户认证,看到一些资料推荐passport-local-mongoose,尝试的做了一下Demo,能跑起来,本来打算根据文档给的方法,自定义一下错误,但是发现不行,我的代码如下

var options = {
    UserExistsError :'用户名已存在!'
};

Account.plugin(passportLocalMongoose,options);

module.exports = mongoose.model('Account', Account);

但是实际情况中


报错仍然如上图所示,不知道有没有人用户passport-local-mongoose这款插件,指导一下错误在哪

PHP中文网PHP中文网2784 days ago544

reply all(1)I'll reply

  • 迷茫

    迷茫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 :'用户名已存在!'}
    };

    reply
    0
  • Cancelreply