Added account restriction on adding new devices.
Ylian Saint-Hilaire committed
Oct 7, 2021 at 19:55 UTC
ecd79e751659d6e28952753a44c8b63c24ea8a6e
2 files changed
+12
-6
meshuser.js
+1
@@ -67,6 +67,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
67
const SITERIGHT_RECORDINGS = 0x00000200; // 512
68
const SITERIGHT_LOCKSETTINGS = 0x00000400; // 1024
69
const SITERIGHT_ALLEVENTS = 0x00000800; // 2048
70
+ const SITERIGHT_NONEWDEVICES = 0x00001000; // 4096
71
const SITERIGHT_ADMIN = 0xFFFFFFFF;
72
73
// Protocol Numbers
views/default.handlebars
+11
-6
@@ -4061,15 +4061,15 @@
4061
r += '</span></td></tr><tr>';
4062
if (mesh.mtype == 1) {
4063
r += '<td><div style=padding:10px><i>' + "No Intel® AMT devices in this device group";
4064
- if ((meshrights & 4) != 0) { r += ', <a href=# style=cursor:pointer onclick=\'return addDeviceToMesh("' + mesh._id + '")\'>' + "add one" + '</a>'; }
4064
+ if (((meshrights & 4) != 0) && ((userinfo.siteadmin == 0xFFFFFFFF) || ((userinfo.siteadmin & 4096) == 0))) { r += ', <a href=# style=cursor:pointer onclick=\'return addDeviceToMesh("' + mesh._id + '")\'>' + "add one" + '</a>'; }
4065
} else if (mesh.mtype == 2) {
4066
r += '<td><div id=DevxCol' + deviceHeaderId2 + ((collapsed === true)?' style=display:none':'') + '>'; // Open collapse div
4067
r += '<div style=padding:10px><i>' + "No devices in this device group";
4068
- if ((meshrights & 4) != 0) { r += ', <a href=# style=cursor:pointer onclick=\'return addAgentToMesh("' + mesh._id + '")\'>' + "add one" + '</a>'; }
4068
+ if (((meshrights & 4) != 0) && ((userinfo.siteadmin == 0xFFFFFFFF) || ((userinfo.siteadmin & 4096) == 0))) { r += ', <a href=# style=cursor:pointer onclick=\'return addAgentToMesh("' + mesh._id + '")\'>' + "add one" + '</a>'; }
4069
} else if (mesh.mtype == 3) {
4070
r += '<td><div id=DevxCol' + deviceHeaderId2 + ((collapsed === true)?' style=display:none':'') + '>'; // Open collapse div
4071
r += '<div style=padding:10px><i>' + "No local devices in this device group";
4072
- if ((meshrights & 4) != 0) { r += ', <a href=# style=cursor:pointer onclick=\'return addLocalDeviceToMesh("' + mesh._id + '")\'>' + "add one" + '</a>'; }
4072
+ if (((meshrights & 4) != 0) && ((userinfo.siteadmin == 0xFFFFFFFF) || ((userinfo.siteadmin & 4096) == 0))) { r += ', <a href=# style=cursor:pointer onclick=\'return addLocalDeviceToMesh("' + mesh._id + '")\'>' + "add one" + '</a>'; }
4073
}
4074
r += '.</i></div></td>';
4075
r += '</div>'; // End collapsing area
@@ -4650,7 +4650,7 @@
4650
r += ' <a href=# style=cursor:pointer;font-size:small title="' + "Perform Intel® AMT activation and configuration." + '" onclick=\'return showAmtSetup("' + mesh._id + '")\'>' + "Setup" + '</a>';
4651
}
4652
}
4653
- if (mesh.mtype == 2) { // Agent device group
4653
+ if ((mesh.mtype == 2) && ((userinfo.siteadmin == 0xFFFFFFFF) || ((userinfo.siteadmin & 4096) == 0))) { // Agent device group
4654
r += ' <a href=# style=cursor:pointer;font-size:small title="' + "Add a new computer to this device group by installing the mesh agent." + '" onclick=\'return addAgentToMesh("' + mesh._id + '")\'>' + "Add Agent" + '</a>';
4655
if ((features & 2) == 0) { r += ' <a href=# style=cursor:pointer;font-size:small title="' + "Invite someone to install the mesh agent on this device group." + '" onclick=\'return inviteAgentToMesh("' + mesh._id + '")\'>' + "Invite" + '</a>'; }
4656
}
@@ -11403,11 +11403,11 @@
11403
x += '<a href=# style=cursor:pointer;margin-right:10px title="' + "Perform Intel® AMT activation and configuration." + '" onclick=\'return showAmtSetup("' + currentMesh._id + '")\'><img src=images/icon-installmesh.png border=0 height=12 width=12> ' + "Setup" + '</a>';
11404
}
11405
}
11406
- if (currentMesh.mtype == 2) {
11406
+ if ((currentMesh.mtype == 2) && ((userinfo.siteadmin == 0xFFFFFFFF) || ((userinfo.siteadmin & 4096) == 0))) {
11407
x += '<a href=# onclick=\'return addAgentToMesh("' + currentMesh._id + '")\' style=cursor:pointer;margin-right:10px title="' + "Add a new computer to this device group by installing the mesh agent." + '"><img src=images/icon-addnew.png border=0 height=12 width=12> ' + "Add Agent" + '</a>';
11408
x += '<a href=# onclick=\'return inviteAgentToMesh("' + currentMesh._id + '")\' style=cursor:pointer;margin-right:10px title="' + "Invite someone to install the mesh agent on this device group." + '"><img src=images/icon-addnew.png border=0 height=12 width=12> ' + "Invite" + '</a>';
11409
}
11410
- if (currentMesh.amt && (currentMesh.amt.type > 2)) { // ACM activation or Full Automatic
11410
+ if (currentMesh.amt && (currentMesh.amt.type > 2) && ((userinfo.siteadmin == 0xFFFFFFFF) || ((userinfo.siteadmin & 4096) == 0))) { // ACM activation or Full Automatic
11411
x += '<a href=# style=cursor:pointer;font-size:small title="' + "Switch Intel AMT to Admin Control Mode (ACM)." + '" onclick=\'return showAmtAcmSetup()\'><img src=images/icon-installmesh.png border=0 height=12 width=12> ' + "ACM" + '</a>';
11412
}
11413
@@ -13582,6 +13582,7 @@
13582
x = '<div><div id=d2AdminPermissions>' + x;
13583
x += '<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_lockedaccount>' + "Lock Account" + '</label><br>';
13584
x += '<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nonewgroups>' + "No New Device Groups" + '</label><br>';
13585
+ x += '<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nonewdevices>' + "No New Devices" + '</label><br>';
13586
x += '<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_nomeshcmd>' + "No Tools (MeshCmd/Router)" + '</label><br>';
13587
x += '<label><input type=checkbox onchange=showUserAdminDialogValidate() id=ua_locksettings>' + "Lock Account Settings" + '</label><br>';
13588
x += '</div>';
@@ -13596,6 +13597,7 @@
13597
Q('ua_nonewgroups').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 64) != 0)); // No New Groups
13598
Q('ua_nomeshcmd').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 128) != 0)); // No Tools (MeshCMD / Router)
13599
Q('ua_locksettings').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 1024) != 0)); // Lock account settings
13600
+ Q('ua_nonewdevices').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 4096) != 0)); // No New Devices
13601
}
13602
if ((userinfo.siteadmin & 2) != 0) {
13603
Q('ua_manageusers').checked = ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 2) != 0)); // Manage Users
@@ -13629,6 +13631,7 @@
13631
QE('ua_lockedaccount', !uself && (userinfo.siteadmin & 2) && (user.siteadmin != 0xFFFFFFFF) && (userinfo._id != user._id));
13632
QE('ua_nonewgroups', !uself && (userinfo.siteadmin & 2) && (user.siteadmin != 0xFFFFFFFF) && (userinfo._id != user._id));
13633
QE('ua_nomeshcmd', !uself && (userinfo.siteadmin & 2) && (user.siteadmin != 0xFFFFFFFF) && (userinfo._id != user._id));
13634
+ QE('ua_nonewdevices', !uself && (userinfo.siteadmin & 2) && (user.siteadmin != 0xFFFFFFFF) && (userinfo._id != user._id));
13635
QE('ua_locksettings', !uself && (userinfo.siteadmin & 2) && (user.siteadmin != 0xFFFFFFFF) && (userinfo._id != user._id));
13636
Q('ua_fileaccessquota').value = (user.quota != null)?(user.quota / 1024):'';
13637
showUserAdminDialogValidate();
@@ -13645,6 +13648,7 @@
13648
QE('ua_lockedaccount', !Q('ua_fulladmin').checked);
13649
QE('ua_nonewgroups', !Q('ua_fulladmin').checked);
13650
QE('ua_nomeshcmd', !Q('ua_fulladmin').checked);
13651
+ QE('ua_nonewdevices', !Q('ua_fulladmin').checked);
13652
QE('ua_manageusergroups', !Q('ua_fulladmin').checked);
13653
QE('ua_managerecordings', !Q('ua_fulladmin').checked);
13654
QE('ua_allevents', !Q('ua_fulladmin').checked);
@@ -13668,6 +13672,7 @@
13672
if (Q('ua_managerecordings').checked == true) siteadmin += 512;
13673
if (Q('ua_locksettings').checked == true) siteadmin += 1024;
13674
if (Q('ua_allevents').checked == true) siteadmin += 2048;
13675
+ if (Q('ua_nonewdevices').checked == true) siteadmin += 4096;
13676
}
13677
var x = { action: 'edituser', id: user._id, siteadmin: siteadmin };
13678
if (isNaN(quota) == false) { x.quota = (quota * 1024); }