dont let sending more than max invites via bulk invite

v1.18.x
Barış Soner Uşaklı 6 years ago
parent c4b23909df
commit 69c7260fe9

@ -288,22 +288,26 @@ SocketUser.invite = function (socket, email, callback) {
if (registrationType === 'admin-invite-only' && !isAdmin) { if (registrationType === 'admin-invite-only' && !isAdmin) {
return next(new Error('[[error:no-privileges]]')); return next(new Error('[[error:no-privileges]]'));
} }
var max = parseInt(meta.config.maximumInvites, 10);
email = email.split(',').map(email => email.trim()).filter(Boolean);
async.eachSeries(email, function (email, next) {
async.waterfall([ async.waterfall([
function (next) { function (next) {
if (max) {
user.getInvitesNumber(socket.uid, next); user.getInvitesNumber(socket.uid, next);
} else {
next(null, 0);
}
}, },
function (invites, next) { function (invites, next) {
var max = parseInt(meta.config.maximumInvites, 10);
if (!isAdmin && max && invites >= max) { if (!isAdmin && max && invites >= max) {
return next(new Error('[[error:invite-maximum-met, ' + invites + ', ' + max + ']]')); return next(new Error('[[error:invite-maximum-met, ' + invites + ', ' + max + ']]'));
} }
email = email.split(',').map(email => email.trim()).filter(Boolean);
async.eachSeries(email, function (email, next) {
user.sendInvitationEmail(socket.uid, email, next); user.sendInvitationEmail(socket.uid, email, next);
}, next);
}, },
], next); ], next);
}, next);
}, },
], callback); ], callback);
}; };

Loading…
Cancel
Save