mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 02:27:22 +02:00
fixes #6415
This commit is contained in:
@@ -180,7 +180,12 @@ module.exports = function (User) {
|
||||
});
|
||||
};
|
||||
|
||||
User.isPasswordValid = function (password, callback) {
|
||||
User.isPasswordValid = function (password, minStrength, callback) {
|
||||
if (typeof minStrength === 'function' && !callback) {
|
||||
callback = minStrength;
|
||||
minStrength = meta.config.minimumPasswordStrength;
|
||||
}
|
||||
|
||||
// Sanity checks: Checks if defined and is string
|
||||
if (!password || !utils.isPasswordValid(password)) {
|
||||
return callback(new Error('[[error:invalid-password]]'));
|
||||
@@ -195,7 +200,7 @@ module.exports = function (User) {
|
||||
}
|
||||
|
||||
var strength = zxcvbn(password);
|
||||
if (strength.score < meta.config.minimumPasswordStrength) {
|
||||
if (strength.score < minStrength) {
|
||||
return callback(new Error('[[user:weak_password]]'));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ module.exports = function (User) {
|
||||
return callback(null, true);
|
||||
}
|
||||
|
||||
User.isPasswordValid(password, next);
|
||||
User.isPasswordValid(password, 0, next);
|
||||
},
|
||||
function (next) {
|
||||
Password.compare(password, hashedPassword, next);
|
||||
|
||||
Reference in New Issue
Block a user