Fixed user group management.

Ylian Saint-Hilaire committed Jan 23, 2022 at 21:57 UTC ba8a73ec7ad3be000fd2b2dddfce71a30d4d3c87
2 files changed +11 -4
meshuser.js
+5 -2
@@ -1474,8 +1474,11 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1474 }
1475
1476 // Get the domain
1477 - var delGroupDomain = parent.parent.config.domains[ugroupidsplit[1]];
1478 - if (delGroupDomain == null) { err = "Invalid domain id"; }
1477 + var delGroupDomain;
1478 + if (ugroupidsplit != null) {
1479 + delGroupDomain = parent.parent.config.domains[ugroupidsplit[1]];
1480 + if (delGroupDomain == null) { err = "Invalid domain id"; }
1481 + }
1482
1483 // Handle any errors
1484 if (err != null) {
views/default.handlebars
+6 -2
@@ -1121,7 +1121,7 @@
1121 <td class="style14">
1122 <div style="float:right">
1123 </div>
1124 - <div>
1124 + <div id="p50userGroupOps">
1125 <input type=button id=UsersGroupsSelectAllButton onclick="p50usersSelectallButtonFunction()" value="Select All" />
1126 <input type=button id=UsersGroupsGroupActionButton disabled="disabled" value="Group Action" onclick=p50usersGroupActionFunction() />
1127 <input id=NewUserGroupButton type=button onclick=showCreateUserGroupDialog(1) value="New Group..." />
@@ -2053,6 +2053,7 @@
2053 // We are user administrator
2054 if (users == null) { meshserver.send({ action: 'users' }); }
2055 if (wssessions == null) { meshserver.send({ action: 'wssessioncount' }); }
2056 + mainUpdate(8192 + 16384);
2057 } else {
2058 // We are not user administrator
2059 users = null;
@@ -14239,6 +14240,9 @@
14240 //
14241
14242 function updateUserGroups() {
14243 + // Display user group operations only if allowed for us
14244 + QV('p50userGroupOps', (userinfo.siteadmin & 256) != 0); // SITERIGHT_USERGROUPS = 256
14245 +
14246 // Sort the list of group names
14247 var sortedGroups = [], x = '';
14248 if (usergroups) { for (var i in usergroups) { sortedGroups.push(usergroups[i]); } }
@@ -14263,7 +14267,7 @@
14267
14268 // Re-check userid's
14269 elements = document.getElementsByClassName('UserGroupCheckbox');
14266 - for (var i=0;i<elements.length;i++) { elements[i].checked = ((checkedUserGroupids.indexOf(elements[i].value) >= 0)); }
14270 + for (var i = 0; i < elements.length; i++) { elements[i].checked = ((checkedUserGroupids.indexOf(elements[i].value) >= 0)); }
14271 p50updateInfo();
14272
14273 // Update current user panel if needed