护照本地猫鼬错误消息更改 [英] passport-local-mongoose Error message change
本文介绍了护照本地猫鼬错误消息更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用护照本地猫鼬中间件更改我的错误消息.但这没用:
I want to change my Error Messages with the passport local mongoose middleware. but it didn't work:
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var passportLocalMongoose = require('passport-local-mongoose');
var Account = new Schema({
username: String,
email: String
});
Account.plugin(passportLocalMongoose,{
IncorrectUsernameError: 'sdfsd',
IncorrectPasswordError: 'sdfsd'
});
var User = mongoose.model('Account', Account);
module.exports = User;
多数民众赞成在我的Account.js和登录/注册工作正常
thats my Account.js and login / register works perfect
我的问题是,当我输入错误的用户名/密码时,会出现旧消息用户名或密码不正确".
And my problem is, when i type in a wrong username/password the old message 'incorrect username or password' appears.
推荐答案
在选项中使用 errorMessages
字段:
var options = {
errorMessages: {
MissingPasswordError: 'No password was given',
AttemptTooSoonError: 'Account is currently locked. Try again later',
TooManyAttemptsError: 'Account locked due to too many failed login attempts',
NoSaltValueStoredError: 'Authentication not possible. No salt value stored',
IncorrectPasswordError: 'Password or username are incorrect',
IncorrectUsernameError: 'Password or username are incorrect',
MissingUsernameError: 'No username was given',
UserExistsError: 'A user with the given username is already registered'
}
};
Account.plugin(passportLocalMongoose,options);
这篇关于护照本地猫鼬错误消息更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文