mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
closes #3607
This commit is contained in:
@@ -13,7 +13,7 @@ define('forum/reset_code', function() {
|
||||
noticeEl = $('#notice');
|
||||
|
||||
resetEl.on('click', function() {
|
||||
if (password.val().length < 6) {
|
||||
if (password.val().length < config.minimumPasswordLength) {
|
||||
app.alertError('[[reset_password:password_too_short]]');
|
||||
} else if (password.val() !== repeat.val()) {
|
||||
app.alertError('[[reset_password:passwords_do_not_match]]');
|
||||
|
||||
@@ -52,11 +52,7 @@ authenticationController.register = function(req, res, next) {
|
||||
return next(new Error('[[error:username-too-long'));
|
||||
}
|
||||
|
||||
if (!userData.password || userData.password.length < meta.config.minimumPasswordLength) {
|
||||
return next(new Error('[[user:change_password_error_length]]'));
|
||||
}
|
||||
|
||||
next();
|
||||
user.isPasswordValid(userData.password, next);
|
||||
},
|
||||
function(next) {
|
||||
plugins.fireHook('filter:register.check', {req: req, res: res, userData: userData}, next);
|
||||
|
||||
@@ -157,7 +157,7 @@ module.exports = function(User) {
|
||||
},
|
||||
passwordValid: function(next) {
|
||||
if (userData.password) {
|
||||
next(!utils.isPasswordValid(userData.password) ? new Error('[[error:invalid-password]]') : null);
|
||||
User.isPasswordValid(userData.password, next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
@@ -179,6 +179,17 @@ module.exports = function(User) {
|
||||
});
|
||||
};
|
||||
|
||||
User.isPasswordValid = function(password, callback) {
|
||||
if (!password || !utils.isPasswordValid(password)) {
|
||||
return callback(new Error('[[error:invalid-password]]'));
|
||||
}
|
||||
|
||||
if (password.length < meta.config.minimumPasswordLength) {
|
||||
return callback(new Error('[[user:change_password_error_length]]'));
|
||||
}
|
||||
callback();
|
||||
};
|
||||
|
||||
function renameUsername(userData, callback) {
|
||||
meta.userOrGroupExists(userData.userslug, function(err, exists) {
|
||||
if (err || !exists) {
|
||||
|
||||
@@ -77,6 +77,9 @@ var async = require('async'),
|
||||
UserReset.commit = function(code, password, callback) {
|
||||
var uid;
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
user.isPasswordValid(password, next);
|
||||
},
|
||||
function(next) {
|
||||
UserReset.validate(code, next);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user