mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-24 13:13:13 -05:00
Added new device details permission.
This commit is contained in:
parent
51a0b3c137
commit
b96c88f1b4
@ -51,6 +51,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
const MESHRIGHT_REMOTECOMMAND = 0x00020000; // 131072
|
||||
const MESHRIGHT_RESETOFF = 0x00040000; // 262144
|
||||
const MESHRIGHT_GUESTSHARING = 0x00080000; // 524288
|
||||
const MESHRIGHT_DEVICEDETAILS = 0x00100000; // 1048576
|
||||
const MESHRIGHT_ADMIN = 0xFFFFFFFF;
|
||||
|
||||
// Site rights
|
||||
@ -5265,6 +5266,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
if ((common.validateStrArray(command.nodeids, 1) == false) && (command.nodeids != null)) break; // Check nodeids
|
||||
if (common.validateString(command.type, 3, 4) == false) break; // Check type
|
||||
getDeviceDetailedInfo(command.nodeids, command.type, function (results, type) {
|
||||
// Remove any device system and network information is we do not have details rights to this device
|
||||
for (var i = 0; i < results.length; i++) { if ((parent.GetNodeRights(user, results[i].node.meshid, results[i].node._id) & MESHRIGHT_DEVICEDETAILS) == 0) { delete results[i].sys; delete results[i].net; } }
|
||||
|
||||
var output = null;
|
||||
if (type == 'csv') {
|
||||
try {
|
||||
@ -5488,7 +5492,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
|
||||
// Get the node and the rights for this node
|
||||
parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
|
||||
if (visible == false) { try { ws.send(JSON.stringify({ action: 'getnetworkinfo', nodeid: command.nodeid, tag: command.tag, noinfo: true, result: 'Invalid device id' })); } catch (ex) { } return; }
|
||||
if ((visible == false) || ((rights & MESHRIGHT_DEVICEDETAILS) == 0)) { try { ws.send(JSON.stringify({ action: 'getnetworkinfo', nodeid: command.nodeid, tag: command.tag, noinfo: true, result: 'Invalid device id' })); } catch (ex) { } return; }
|
||||
|
||||
// Get network information about this node
|
||||
db.Get('if' + node._id, function (err, netinfos) {
|
||||
@ -5513,7 +5517,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
|
||||
// Get the node and the rights for this node
|
||||
parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
|
||||
if (visible == false) { try { ws.send(JSON.stringify({ action: 'getsysinfo', nodeid: command.nodeid, tag: command.tag, noinfo: true, result: 'Invalid device id' })); } catch (ex) { } return; }
|
||||
if ((visible == false) || ((rights & MESHRIGHT_DEVICEDETAILS) == 0)) { try { ws.send(JSON.stringify({ action: 'getsysinfo', nodeid: command.nodeid, tag: command.tag, noinfo: true, result: 'Invalid device id' })); } catch (ex) { } return; }
|
||||
// Query the database system information
|
||||
db.Get('si' + command.nodeid, function (err, docs) {
|
||||
if ((docs != null) && (docs.length > 0)) {
|
||||
|
@ -3548,7 +3548,7 @@
|
||||
) { menus.push({ n: "Terminal", f: 'setupDeviceMenu(5)' }); }
|
||||
|
||||
if ((currentDevicePanel != 2) && (currentNode != null) && (meshrights & 8) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 1024) == 0)) && ((currentNode.mtype != 1) && (currentNode.agent.caps & 4))) { menus.push({ n: "Files", f: 'setupDeviceMenu(2)' }); }
|
||||
if ((currentDevicePanel != 3) && (currentNode != null) && (currentNode.mtype != 3)) { menus.push({ n: "Details", f: 'setupDeviceMenu(3)' }); }
|
||||
if ((currentDevicePanel != 3) && (currentNode != null) && (currentNode.mtype != 3) && ((meshrights & 1048576) != 0)) { menus.push({ n: "Details", f: 'setupDeviceMenu(3)' }); }
|
||||
if ((currentDevicePanel != 4) && (currentNode != null) && (meshrights & 0x00000010) && (currentNode.mtype == 2)) { menus.push({ n: "Console", f: 'setupDeviceMenu(4)' }); }
|
||||
updateFooterMenu(menus);
|
||||
updateCurrentUrl();
|
||||
|
@ -6602,7 +6602,7 @@
|
||||
x += ' <a href=# onclick=p10showDeleteNodeDialog("' + node._id + '") title="' + "Remove this device" + '">' + "Delete Device" + '</a>';
|
||||
}
|
||||
x += '</div><div class="p10html3left">';
|
||||
if ((node.agent) && (node.mtype != 3)) x += '<a href=# onclick=p10showNodeNetInfoDialog("' + node._id + '") title="' + "Show device network interface information" + '">' + "Interfaces" + '</a> ';
|
||||
if ((node.agent) && (node.mtype != 3) && ((meshrights & 1048576) != 0)) x += '<a href=# onclick=p10showNodeNetInfoDialog("' + node._id + '") title="' + "Show device network interface information" + '">' + "Interfaces" + '</a> ';
|
||||
if ((features & 0x00008000) && (xxmap != null)) x += '<a href=# onclick=p10showNodeLocationDialog("' + node._id + '") title="' + "Show device locations information" + '">' + "Location" + '</a> ';
|
||||
if ((node.agent == null) || ((node.agent.id != 14) && (node.agent.id != 34))) {
|
||||
if ((userinfo.siteadmin == 0xFFFFFFFF) || ((userinfo.siteadmin & 128) == 0)) { // Check if we should view tools
|
||||
@ -6710,7 +6710,7 @@
|
||||
);
|
||||
QV('MainDevTerminal', (((node.agent == null) && (node.intelamt != null)) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (meshrights & 8) && terminalAccess);
|
||||
QV('MainDevFiles', (node.agent != null) && (node.agent.caps != null) && ((node.agent.caps & 4) != 0) && (meshrights & 8) && fileAccess);
|
||||
QV('MainDevInfo', (node.mtype != 3));
|
||||
QV('MainDevInfo', (node.mtype != 3) & (meshrights & 1048576));
|
||||
QV('MainDevAmt', (node.intelamt != null) && ((node.intelamt.state == 2) || (node.conn & 2)) && (meshrights & 8) && amtAccess);
|
||||
QV('MainDevConsole', (consoleRights && ((node.agent != null) && (node.agent.caps != null) && ((node.agent.caps & 8) != 0))) && (meshrights & 8));
|
||||
QV('MainDevPlugins', false);
|
||||
@ -11546,6 +11546,7 @@
|
||||
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20uninstall>' + "Uninstall Agent / Delete Device" + '</label><br>';
|
||||
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20commands>' + "Remote Commands" + '</label><br>';
|
||||
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20resetoff>' + "Reset / Power Off" + '</label><br>';
|
||||
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20details>' + "Device Details" + '</label><br>';
|
||||
x += '</div>';
|
||||
|
||||
if (userid == null) {
|
||||
@ -11622,6 +11623,7 @@
|
||||
if (urights & 131072) { Q('p20commands').checked = true; }
|
||||
if (urights & 262144) { Q('p20resetoff').checked = true; }
|
||||
if ((urights & 524288) && (serverinfo.guestdevicesharing !== false)) { Q('p20guestshare').checked = true; }
|
||||
if (urights & 1048576) { Q('p20details').checked = true; }
|
||||
}
|
||||
|
||||
p20validateAddMeshUserDialog(userid);
|
||||
@ -11669,6 +11671,7 @@
|
||||
Q('p20commands').checked = ((devrights & 131072) != 0);
|
||||
Q('p20resetoff').checked = ((devrights & 262144) != 0);
|
||||
if (serverinfo.guestdevicesharing !== false) { Q('p20guestshare').checked = ((devrights & 524288) != 0); }
|
||||
Q('p20details').checked = ((devrights & 1048576) != 0);
|
||||
ok = (nodeid != '');
|
||||
}
|
||||
|
||||
@ -11749,6 +11752,7 @@
|
||||
QE('p20uninstall', nc);
|
||||
QE('p20commands', nc);
|
||||
QE('p20resetoff', nc);
|
||||
QE('p20details', nc);
|
||||
}
|
||||
|
||||
function p20showAddMeshUserDialogEx(b, t) {
|
||||
@ -11777,6 +11781,7 @@
|
||||
if (Q('p20commands').checked == true) meshadmin += 131072;
|
||||
if (Q('p20resetoff').checked == true) meshadmin += 262144;
|
||||
if ((serverinfo.guestdevicesharing !== false) && (Q('p20guestshare').checked == true) && (Q('p20remoteview').checked || (!Q('p20remoteview').checked && !Q('p20remotelimitedinput').checked))) meshadmin += 524288;
|
||||
if (Q('p20details').checked == true) meshadmin += 1048576;
|
||||
}
|
||||
|
||||
// Clean up incorrect rights. If Remote Control is not selected, remove flags that don't make sense.
|
||||
@ -11860,6 +11865,8 @@
|
||||
if ((meshrights & 32768) != 0) r.push("Uninstall");
|
||||
if ((meshrights & 131072) != 0) r.push("Commands");
|
||||
if ((meshrights & 262144) != 0) r.push("Reset/Off");
|
||||
if ((meshrights & 524288) != 0) r.push("Sharing");
|
||||
if ((meshrights & 1048576) != 0) r.push("Details");
|
||||
}
|
||||
if (r.length == 0) { r.push("No Rights"); }
|
||||
var uname = xuserid.split('/')[2];
|
||||
|
Loading…
x
Reference in New Issue
Block a user