diff --git a/src/events.js b/src/events.js index f6fe006d02..1c6aeae09c 100644 --- a/src/events.js +++ b/src/events.js @@ -30,6 +30,8 @@ events.types = [ 'topic-purge', 'topic-rename', 'password-reset', + 'user-makeAdmin', + 'user-removeAdmin', 'user-ban', 'user-unban', 'user-delete', diff --git a/src/socket.io/admin/user.js b/src/socket.io/admin/user.js index 02ade56a89..87b6b798ca 100644 --- a/src/socket.io/admin/user.js +++ b/src/socket.io/admin/user.js @@ -28,8 +28,20 @@ User.makeAdmins = function (socket, uids, callback) { } } - async.each(uids, function (uid, next) { - groups.join('administrators', uid, next); + async.eachSeries(uids, function (uid, next) { + async.waterfall([ + function (next) { + groups.join('administrators', uid, next); + }, + function (next) { + events.log({ + type: 'user-makeAdmin', + uid: socket.uid, + targetUid: uid, + ip: socket.ip, + }, next); + }, + ], next); }, next); }, ], callback); @@ -52,6 +64,14 @@ User.removeAdmins = function (socket, uids, callback) { groups.leave('administrators', uid, next); }, + function (next) { + events.log({ + type: 'user-removeAdmin', + uid: socket.uid, + targetUid: uid, + ip: socket.ip, + }, next); + }, ], next); }, callback); };