app.isAdmin available client-side

v1.18.x
psychobunny 11 years ago
parent 1c1c5da8f2
commit 609821029b

@ -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', {

@ -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
});
});

Loading…
Cancel
Save