mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 02:25:55 +01:00
prevent crash on invalid data
This commit is contained in:
@@ -70,23 +70,29 @@ SocketPosts.reply = function(socket, data, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SocketPosts.getVoters = function(socket, data, callback) {
|
SocketPosts.getVoters = function(socket, data, callback) {
|
||||||
var pid = data.pid,
|
if (!data || !data.pid || !data.cid) {
|
||||||
cid = data.cid,
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
uid = socket.uid;
|
}
|
||||||
|
|
||||||
async.parallel([
|
var pid = data.pid,
|
||||||
function(next) {
|
cid = data.cid;
|
||||||
user.isAdministrator(uid, next);
|
|
||||||
|
async.parallel({
|
||||||
|
isAdmin: function(next) {
|
||||||
|
user.isAdministrator(socket.uid, next);
|
||||||
},
|
},
|
||||||
function(next) {
|
isModerator: function(next) {
|
||||||
user.isModerator(uid, cid, next);
|
user.isModerator(socket.uid, cid, next);
|
||||||
}
|
}
|
||||||
], function(err, tests) {
|
}, function(err, tests) {
|
||||||
if (tests[0] || tests[1]) {
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tests.isAdmin || tests.isModerator) {
|
||||||
getVoters(pid, callback);
|
getVoters(pid, callback);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function getVoters(pid, callback) {
|
function getVoters(pid, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user