mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +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) { | ||||
| 	var pid = data.pid, | ||||
| 		cid = data.cid, | ||||
| 		uid = socket.uid; | ||||
|  | ||||
| 	async.parallel([ | ||||
| 		function(next) { | ||||
| 			user.isAdministrator(uid, next); | ||||
| 		}, | ||||
| 		function(next) { | ||||
| 			user.isModerator(uid, cid, next); | ||||
| 	if (!data || !data.pid || !data.cid) { | ||||
| 		return callback(new Error('[[error:invalid-data]]')); | ||||
| 	} | ||||
| 	], function(err, tests) { | ||||
| 		if (tests[0] || tests[1]) { | ||||
|  | ||||
| 	var pid = data.pid, | ||||
| 		cid = data.cid; | ||||
|  | ||||
| 	async.parallel({ | ||||
| 		isAdmin: function(next) { | ||||
| 			user.isAdministrator(socket.uid, next); | ||||
| 		}, | ||||
| 		isModerator: function(next) { | ||||
| 			user.isModerator(socket.uid, cid, next); | ||||
| 		} | ||||
| 	}, function(err, tests) { | ||||
| 		if (err) { | ||||
| 			return callback(err); | ||||
| 		} | ||||
|  | ||||
| 		if (tests.isAdmin || tests.isModerator) { | ||||
| 			getVoters(pid, callback); | ||||
| 		} | ||||
| 	}) | ||||
|  | ||||
| 	}); | ||||
| }; | ||||
|  | ||||
| function getVoters(pid, callback) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user