diff --git a/public/src/app.js b/public/src/app.js index 78a1c9228f..2e1c1f9204 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -34,6 +34,7 @@ var socket, socket.on('event:connect', function (data) { app.username = data.username; app.uid = data.uid; + app.isAdmin = data.isAdmin; app.showLoginMessage(); socket.emit('meta.updateHeader', { diff --git a/src/socket.io/index.js b/src/socket.io/index.js index b92c0f7e3f..9e5b6205af 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -88,10 +88,22 @@ Sockets.init = function(server) { db.sortedSetAdd('users:online', Date.now(), uid, function(err, data) { socket.join('uid_' + uid); - user.getUserField(uid, 'username', function(err, username) { + async.parallel({ + username: function(next) { + user.getUserField(uid, 'username', function(err, username) { + next(err, username); + }); + }, + isAdmin: function(next) { + user.isAdministrator(uid, function(err, isAdmin) { + next(err, isAdmin); + }); + } + }, function(err, userData) { socket.emit('event:connect', { status: 1, - username: username, + username: userData.username, + isAdmin: userData.isAdmin, uid: uid }); });