mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
closes #6875
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user