diff --git a/meshuser.js b/meshuser.js
index c5ff0933..9f52dd40 100644
--- a/meshuser.js
+++ b/meshuser.js
@@ -1476,12 +1476,24 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
}
case 'usergroups':
{
- if ((user.siteadmin & SITERIGHT_USERGROUPS) == 0) { return; }
+ // TODO: Return only groups in the same administrative domain?
+ if ((user.siteadmin & SITERIGHT_USERGROUPS) == 0) {
+ // We are not user group administrator, return a list with limited data.
+ var groups = {}, groupCount = 0;
+ for (var i in parent.userGroups) { groupCount++; groups[i] = { name: parent.userGroups[i].name }; }
+ try { ws.send(JSON.stringify({ action: 'usergroups', ugroups: groupCount?groups:null, tag: command.tag })); } catch (ex) { }
+ } else {
+ // We are user group administrator, return a full user group list.
+ try { ws.send(JSON.stringify({ action: 'usergroups', ugroups: parent.userGroups, tag: command.tag })); } catch (ex) { }
+ }
+ /*
// Request a list of all user groups this user as rights to
+ if ((user.siteadmin & SITERIGHT_USERGROUPS) == 0) { return; }
db.GetAllTypeNoTypeField('ugrp', domain.id, function (err, docs) {
try { ws.send(JSON.stringify({ action: 'usergroups', ugroups: common.unEscapeAllLinksFieldName(docs), tag: command.tag })); } catch (ex) { }
});
+ */
break;
}
case 'createusergroup':
diff --git a/views/default.handlebars b/views/default.handlebars
index 9e980009..56656218 100644
--- a/views/default.handlebars
+++ b/views/default.handlebars
@@ -1723,9 +1723,15 @@
}
case 'usergroups': {
var groupCount = 0;
- usergroups = {};
- for (var i in message.ugroups) { groupCount++; usergroups[message.ugroups[i]._id] = message.ugroups[i]; }
- if (groupCount == 0) { usergroups = null; }
+ if (Array.isArray(message.ugroups)) {
+ usergroups = {};
+ for (var i in message.ugroups) { groupCount++; usergroups[message.ugroups[i]._id] = message.ugroups[i]; }
+ if (groupCount == 0) { usergroups = null; }
+ } else {
+ usergroups = message.ugroups;
+ for (var i in message.ugroups) { groupCount++; }
+ if (groupCount == 0) { usergroups = null; }
+ }
masterUpdate(8192);
break;
}
@@ -2249,7 +2255,7 @@
// A new mesh was created
if ((meshes[message.event.meshid] == null) && (message.event.links[userinfo._id] != null)) { // Check if this is a mesh create for a mesh we own. If site administrator, we get all messages so need to ignore some.
meshes[message.event.meshid] = { _id: message.event.meshid, name: message.event.name, mtype: message.event.mtype, desc: message.event.desc, links: message.event.links };
- masterUpdate(4 + 128);
+ masterUpdate(4 + 128 + 8192 + 16384);
meshserver.send({ action: 'files' });
}
break;
@@ -2286,7 +2292,7 @@
if (xxcurrentView >= 10 && xxcurrentView < 20 && currentNode && currentNode.meshid == message.event.meshid) { setDialogMode(0); go(1); }
}
}
- masterUpdate(4 + 128);
+ masterUpdate(4 + 128 + 8192 + 16384);
if (currentNode && (currentNode.meshid == message.event.meshid)) { currentNode = null; if ((xxcurrentView >= 10) && (xxcurrentView < 20)) { go(1); } }
//meshserver.send({ action: 'files' }); // TODO: Why do we need to do this??
@@ -2306,7 +2312,7 @@
var newnodes = [];
if (nodes != null) { for (var i in nodes) { if (nodes[i].meshid != message.event.meshid) { newnodes.push(nodes[i]); } } }
nodes = newnodes;
- masterUpdate(4);
+ masterUpdate(4 + 8192 + 16384);
// If we are looking at a mesh that is now deleted, move back to "My Account"
if (xxcurrentView >= 20 && xxcurrentView < 30 && currentMesh._id == message.event.meshid) { setDialogMode(0); go(2); }
@@ -7660,7 +7666,7 @@
x += '
';
if (meshrights & 2) {
x += ' ' + "Add Users" + '';
- if ((usergroups != null) && ((userinfo.siteadmin & 256) != 0)) {
+ if (usergroups != null) {
var userGroupCount = 0, newUserGroup = false;
for (var i in usergroups) { userGroupCount++; if ((currentMesh.links == null) || (currentMesh.links[i] == null)) { newUserGroup = true; } }
if ((userGroupCount > 0) && (newUserGroup)) { x += ' ' + "Add User Group" + ''; }
@@ -7898,7 +7904,7 @@
for (var i in meshes) { if ((currentUser.links == null) || (currentUser.links[i] == null)) { y += ''; } }
x += addHtmlValue("Device Group", '