Skip to content

Node.js based forum software built for the modern web

closes #3607

barisusakli30d087cbd31b
diff --git a/public/src/client/reset_code.js b/public/src/client/reset_code.js
index abbc4582db..678edf987a 100644
--- a/public/src/client/reset_code.js
+++ b/public/src/client/reset_code.js
@@ -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]]');
diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js
index beb319b04c..043776eda2 100644
--- a/src/controllers/authentication.js
+++ b/src/controllers/authentication.js
@@ -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);
diff --git a/src/user/create.js b/src/user/create.js
index 1a6e2a40e8..ed04c2cd75 100644
--- a/src/user/create.js
+++ b/src/user/create.js
@@ -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) {
diff --git a/src/user/reset.js b/src/user/reset.js
index e9a5e46c1a..26acc5ecbc 100644
--- a/src/user/reset.js
+++ b/src/user/reset.js
@@ -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);
},