Removed user group remove permissions, #3129.

Ylian Saint-Hilaire committed Sep 15, 2021 at 08:56 UTC f4cb2bab1eb348845ca6a6396980b6bd51e69061
3 files changed +14 -66
meshuser.js
+1 -6
@@ -1951,14 +1951,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1951 if (change == '') { change = 'User group features changed.'; }
1952 }
1953
1954 - if ((command.removeRights != null) && (typeof command.removeRights == 'number')) {
1955 - if ((command.removeRights == 0) && (group.removeRights != null)) { delete group.removeRights; } else { if (command.removeRights !== group.removeRights) { group.removeRights = command.removeRights; } }
1956 - if (change == '') { change = 'User group features changed.'; }
1957 - }
1958 -
1954 if (change != '') {
1955 db.Set(group);
1961 - var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: group._id, name: group.name, desc: group.desc, consent: ((group.consent == null) ? 0 : group.consent), action: 'usergroupchange', links: group.links, flags: group.flags, removeRights: group.removeRights, msg: change, domain: domain.id };
1956 + var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: group._id, name: group.name, desc: group.desc, consent: ((group.consent == null) ? 0 : group.consent), action: 'usergroupchange', links: group.links, flags: group.flags, msg: change, domain: domain.id };
1957 if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
1958 parent.parent.DispatchEvent(['*', group._id, user._id], obj, event);
1959 }
views/default-mobile.handlebars
-1
@@ -1744,7 +1744,6 @@
1744 ugroup.desc = message.event.desc;
1745 ugroup.links = message.event.links;
1746 ugroup.flags = message.event.flags;
1747 - ugroup.removeRights = message.event.removeRights;
1747 }
1748 //mainUpdate(8192 + 16384);
1749
views/default.handlebars
+13 -59
@@ -2936,7 +2936,6 @@
2936 if (message.event.desc) { ugroup.desc = message.event.desc; } else { delete ugroup.desc; }
2937 if (message.event.links) { ugroup.links = message.event.links; } else { delete ugroup.links; }
2938 if (message.event.flags) { ugroup.flags = message.event.flags; } else { delete ugroup.flags; }
2939 - if (message.event.removeRights) { ugroup.removeRights = message.event.removeRights; } else { delete ugroup.removeRights; }
2939 if (typeof message.event.consent == 'number') { ugroup.consent = message.event.consent; }
2940 }
2941 mainUpdate(4096 + 8192 + 16384);
@@ -13831,24 +13830,13 @@
13830 }
13831
13832 // Display features
13834 - var userGroupFeatures = [];
13835 - if ((serverinfo.userGroupsSessionRecording == 1) && (group.flags) && (group.flags & 2)) { userGroupFeatures.push("Record Sessions"); }
13836 - if (group.removeRights) {
13837 - if ((group.removeRights & 0x00000008) != 0) { userGroupFeatures.push("No Remote Control"); } else {
13838 - if ((group.removeRights & 0x00010000) != 0) { userGroupFeatures.push("No Desktop"); }
13839 - else if ((group.removeRights & 0x00000100) != 0) { userGroupFeatures.push("Desktop View Only"); }
13840 - if ((group.removeRights & 0x00000200) != 0) { userGroupFeatures.push("No Terminal"); }
13841 - if ((group.removeRights & 0x00000400) != 0) { userGroupFeatures.push("No Files"); }
13842 - }
13843 - if ((group.removeRights & 0x00000010) != 0) { userGroupFeatures.push("No Console"); }
13844 - if ((group.removeRights & 0x00008000) != 0) { userGroupFeatures.push("No Uninstall"); }
13845 - if ((group.removeRights & 0x00020000) != 0) { userGroupFeatures.push("No Remote Command"); }
13846 - if ((group.removeRights & 0x00000040) != 0) { userGroupFeatures.push("No Wake"); }
13847 - if ((group.removeRights & 0x00040000) != 0) { userGroupFeatures.push("No Reset/Off"); }
13848 - }
13849 - userGroupFeatures = userGroupFeatures.join(', ');
13850 - if (userGroupFeatures == '') { userGroupFeatures = '<i>' + "None" + '</i>'; }
13851 - x += addDeviceAttribute("Features", addLink(userGroupFeatures, 'p51edituserGroupFeatures()'));
13833 + if (serverinfo.userGroupsSessionRecording == 1) {
13834 + var userGroupFeatures = [];
13835 + if ((group.flags) && (group.flags & 2)) { userGroupFeatures.push("Record Sessions"); }
13836 + userGroupFeatures = userGroupFeatures.join(', ');
13837 + if (userGroupFeatures == '') { userGroupFeatures = '<i>' + "None" + '</i>'; }
13838 + x += addDeviceAttribute("Features", addLink(userGroupFeatures, 'p51edituserGroupFeatures()'));
13839 + }
13840
13841 // Display user consent flags for this user group
13842 {
@@ -13975,53 +13963,19 @@
13963
13964 function p51edituserGroupFeatures() {
13965 if (xxdialogMode) return;
13978 - var flags = (currentUserGroup.flags)?currentUserGroup.flags:0, x = ''; // Flags: 1 = Account Image, 2 = Session Recording
13979 - var removeRights = (currentUserGroup.removeRights)?currentUserGroup.removeRights:0, x = ''; // Remove Device Group Rights
13966 + var flags = (currentUserGroup.flags)?currentUserGroup.flags:0, x = ''; // Flags: 2 = Session Recording
13967 if (serverinfo.userGroupsSessionRecording == 1) {
13981 - x += '<div><label><input type=checkbox id=d51flag1 onchange=p51edituserGroupFeaturesValidate() ' + ((flags & 2) ? 'checked' : '') + '>' + "Record sessions" + '</label><br></div>';
13982 - }
13983 - x += '<div><label><input type=checkbox id=d51flag7 onchange=p51edituserGroupFeaturesValidate() ' + ((removeRights & 0x00000008) ? 'checked' : '') + '>' + "No Remote Control" + '</label><br></div>';
13984 - x += '<div style=margin-left:8px><label><input type=checkbox id=d51flag2 onchange=p51edituserGroupFeaturesValidate() ' + ((removeRights & 0x00010000) ? 'checked' : '') + '>' + "No Desktop Access" + '</label><br></div>';
13985 - x += '<div style=margin-left:16px><label><input type=checkbox id=d51flag3 onchange=p51edituserGroupFeaturesValidate() ' + ((removeRights & 0x00000100) ? 'checked' : '') + '>' + "Remote View Only" + '</label><br></div>';
13986 - x += '<div style=margin-left:8px><label><input type=checkbox id=d51flag4 onchange=p51edituserGroupFeaturesValidate() ' + ((removeRights & 0x00000200) ? 'checked' : '') + '>' + "No Terminal Access" + '</label><br></div>';
13987 - x += '<div style=margin-left:8px><label><input type=checkbox id=d51flag5 onchange=p51edituserGroupFeaturesValidate() ' + ((removeRights & 0x00000400) ? 'checked' : '') + '>' + "No File Access" + '</label><br></div>';
13988 - x += '<div><label><input type=checkbox id=d51flag6 onchange=p51edituserGroupFeaturesValidate() ' + ((removeRights & 0x00000010) ? 'checked' : '') + '>' + "No Agent Console" + '</label><br></div>';
13989 - x += '<div><label><input type=checkbox id=d51flag8 onchange=p51edituserGroupFeaturesValidate() ' + ((removeRights & 0x00008000) ? 'checked' : '') + '>' + "No Uninstall" + '</label><br></div>';
13990 - x += '<div><label><input type=checkbox id=d51flag9 onchange=p51edituserGroupFeaturesValidate() ' + ((removeRights & 0x00020000) ? 'checked' : '') + '>' + "No Remote Command" + '</label><br></div>';
13991 - x += '<div><label><input type=checkbox id=d51flag10 onchange=p51edituserGroupFeaturesValidate() ' + ((removeRights & 0x00000040) ? 'checked' : '') + '>' + "No Wake" + '</label><br></div>';
13992 - x += '<div><label><input type=checkbox id=d51flag11 onchange=p51edituserGroupFeaturesValidate() ' + ((removeRights & 0x00040000) ? 'checked' : '') + '>' + "No Reset/Off" + '</label><br></div>';
13968 + x += '<div><label><input type=checkbox id=d51flag1 ' + ((flags & 2) ? 'checked' : '') + '>' + "Record sessions" + '</label><br></div>';
13969 + }
13970 setDialogMode(2, "Edit User Group Features", 3, p51edituserGroupFeaturesEx, x);
13994 - p51edituserGroupFeaturesValidate();
13995 - }
13996 -
13997 - function p51edituserGroupFeaturesValidate() {
13998 - QE('d51flag2', !Q('d51flag7').checked);
13999 - QE('d51flag3', !Q('d51flag7').checked && !Q('d51flag2').checked);
14000 - QE('d51flag4', !Q('d51flag7').checked);
14001 - QE('d51flag5', !Q('d51flag7').checked);
13971 }
13972
13973 // Send to the server the new user's real name
13974 function p51edituserGroupFeaturesEx() {
13975 // Setup user flags
14007 - var flags = (currentUserGroup.flags)?currentUserGroup.flags:0; // Flags: 1 = Account Image, 2 = Session Recording
14008 - var f = flags & 1;
14009 - if ((serverinfo.userGroupsSessionRecording == 1) && Q('d51flag1').checked) { f += 2; }
14010 -
14011 - // Setup user permission removal
14012 - var r = 0;
14013 - if (Q('d51flag7').checked) { r += 0x00000008; } else {
14014 - if (Q('d51flag2').checked) { r += 0x00010000; }
14015 - else if (Q('d51flag3').checked) { r += 0x00000100; }
14016 - if (Q('d51flag4').checked) { r += 0x00000200; }
14017 - if (Q('d51flag5').checked) { r += 0x00000400; }
14018 - }
14019 - if (Q('d51flag6').checked) { r += 0x00000010; }
14020 - if (Q('d51flag8').checked) { r += 0x00008000; }
14021 - if (Q('d51flag9').checked) { r += 0x00020000; }
14022 - if (Q('d51flag10').checked) { r += 0x00000040; }
14023 - if (Q('d51flag11').checked) { r += 0x00040000; }
14024 - meshserver.send({ action: 'editusergroup', ugrpid: currentUserGroup._id, flags: f, removeRights: r });
13976 + var flags = 0; // Flags: 2 = Session Recording
13977 + if ((serverinfo.userGroupsSessionRecording == 1) && Q('d51flag1').checked) { flags += 2; }
13978 + meshserver.send({ action: 'editusergroup', ugrpid: currentUserGroup._id, flags: flags });
13979 }
13980
13981 function p51removeDeviceFromUserGroup(e, nodeid) {