Node.js based forum software built for the modern web
closes #6875
Barış Soner Uşaklı66ed48e08834
diff --git a/src/controllers/authentication.js b/src/controllers/authentication.jsindex 5bdb9fbc57..1c3e1b4ab0 100644--- a/src/controllers/authentication.js+++ b/src/controllers/authentication.js@@ -164,6 +164,10 @@ authenticationController.registerComplete = function (req, res, next) {var done = function (err, data) {delete req.session.registration;+ if (err) {+ return res.redirect(nconf.get('relative_path') + '/?register=' + encodeURIComponent(err.message));+ }+if (!err && data && data.message) {return res.redirect(nconf.get('relative_path') + '/?register=' + encodeURIComponent(data.message));}diff --git a/src/user/approval.js b/src/user/approval.jsindex a42c400109..db78ea65e7 100644--- a/src/user/approval.js+++ b/src/user/approval.js@@ -20,7 +20,7 @@ module.exports = function (User) {userData.userslug = utils.slugify(userData.username);async.waterfall([function (next) {- User.isDataValid(userData, next);+ canQueue(userData, next);},function (next) {User.hashPassword(userData.password, next);@@ -46,6 +46,31 @@ module.exports = function (User) {], callback);};+ function canQueue(userData, callback) {+ async.waterfall([+ function (next) {+ User.isDataValid(userData, next);+ },+ function (next) {+ db.getSortedSetRange('registration:queue', 0, -1, next);+ },+ function (usernames, next) {+ if (usernames.includes(userData.username)) {+ return next(new Error('[[error:username-taken]]'));+ }+ const keys = usernames.filter(Boolean).map(username => 'registration:queue:name:' + username);+ db.getObjectsFields(keys, ['email'], next);+ },+ function (data, next) {+ const emails = data.map(data => data && data.email);+ if (emails.includes(userData.email)) {+ return next(new Error('[[error:email-taken]]'));+ }+ next();+ },+ ], callback);+ }+function sendNotificationToAdmins(username, callback) {async.waterfall([function (next) {