From da729241870686f7bca88325bb8647a4ba00e7eb Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 13 May 2014 16:44:40 -0400 Subject: [PATCH] removed duplication --- src/socket.io/admin/user.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/socket.io/admin/user.js b/src/socket.io/admin/user.js index a07cdc1be8..80153c46b9 100644 --- a/src/socket.io/admin/user.js +++ b/src/socket.io/admin/user.js @@ -35,12 +35,19 @@ User.createUser = function(socket, userData, callback) { }; User.banUsers = function(socket, uids, callback) { + toggleBan(uids, User.banUser, callback); +}; + +User.unbanUsers = function(socket, uids, callback) { + toggleBan(uids, user.unban, callback); +}; + +function toggleBan(uids, method callback) { if(!Array.isArray(uids)) { return callback(new Error('[[error:invalid-data]]')); } - - async.each(uids, User.banUser, callback); -}; + async.each(uids, method, callback); +} User.banUser = function(uid, callback) { user.isAdministrator(uid, function(err, isAdmin) { @@ -65,13 +72,6 @@ User.banUser = function(uid, callback) { }); }; -User.unbanUsers = function(socket, uids, callback) { - if(!Array.isArray(uids)) { - return callback(new Error('[[error:invalid-data]]')); - } - async.each(uids, user.unban, callback); -}; - User.deleteUsers = function(socket, uids, callback) { if(!Array.isArray(uids)) { return callback(new Error('[[error:invalid-data]]'));