Node.js based forum software built for the modern web
closes #2377
barisusakli519b1b7e3714
diff --git a/public/language/en_GB/error.json b/public/language/en_GB/error.jsonindex 53987d73d2..40b685354d 100644--- a/public/language/en_GB/error.json+++ b/public/language/en_GB/error.json@@ -85,5 +85,7 @@"not-enough-reputation-to-downvote": "You do not have enough reputation to downvote this post","not-enough-reputation-to-flag": "You do not have enough reputation to flag this post",- "reload-failed": "NodeBB encountered a problem while reloading: \"%1\". NodeBB will continue to serve the existing client-side assets, although you should undo what you did just prior to reloading."+ "reload-failed": "NodeBB encountered a problem while reloading: \"%1\". NodeBB will continue to serve the existing client-side assets, although you should undo what you did just prior to reloading.",++ "registration-error": "Registration Error"}\ No newline at end of filediff --git a/src/controllers/index.js b/src/controllers/index.jsindex aaba36dcd6..e92f856bc9 100644--- a/src/controllers/index.js+++ b/src/controllers/index.js@@ -179,6 +179,7 @@ Controllers.register = function(req, res, next) {data.minimumPasswordLength = meta.config.minimumPasswordLength;data.termsOfUse = meta.config.termsOfUse;data.regFormEntry = [];+ data.error = req.flash('error')[0];plugins.fireHook('filter:register.build', {req: req, res: res, templateData: data}, function(err, data) {if (err && process.env === 'development') {diff --git a/src/routes/authentication.js b/src/routes/authentication.jsindex 1216968494..f6fe08d5d5 100644--- a/src/routes/authentication.js+++ b/src/routes/authentication.js@@ -207,14 +207,20 @@}}- if (!userData.username || userData.username.length < meta.config.minimumUsernameLength) {- return res.redirect(nconf.get('relative_path') + '/register?error=[[error:username-too-short]]');- } else if (!userData.username || userData.username.length > meta.config.maximumUsernameLength) {- return res.redirect(nconf.get('relative_path') + '/register?error=[[error:username-too-long]]');- }-var uid;async.waterfall([+ function(next) {+ if (!userData.username || userData.username.length < meta.config.minimumUsernameLength) {+ return next(new Error('[[error:username-too-short]]'));+ }+ next();+ },+ function(next) {+ if (!userData.username || userData.username.length > meta.config.maximumUsernameLength) {+ return next(new Error('[[error:username-too-long'));+ }+ next();+ },function(next) {plugins.fireHook('filter:register.check', {req: req, res: res, userData: userData}, next);},@@ -236,7 +242,8 @@}], function(err, data) {if (err) {- return res.redirect(nconf.get('relative_path') + '/register?error=' + err.message);+ req.flash('error', err.message);+ return res.redirect(nconf.get('relative_path') + '/register');}res.redirect(nconf.get('relative_path') + (data.referrer ? data.referrer : '/'));});