v1.18.x
Barış Soner Uşaklı 6 years ago
parent aa301f27a1
commit 66ed48e088

@ -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) {

Loading…
Cancel
Save