diff --git a/meshrelay.js b/meshrelay.js index 23296c06..ab593a8b 100644 --- a/meshrelay.js +++ b/meshrelay.js @@ -80,44 +80,36 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie var agent = parent.wsagents[command.nodeid]; if (agent != null) { // Check if we have permission to send a message to that node - parent.GetNodeWithRights(domain, user, agent.dbNodeKey, function (node, rights, visible) { - mesh = parent.meshes[agent.dbMeshKey]; - if ((node != null) && (rights != null) && (mesh != null) || ((rights & 16) != 0)) { // TODO: 16 is console permission, may need more gradular permission checking - if (ws.sessionId) { command.sessionid = ws.sessionId; } // Set the session id, required for responses. - command.rights = rights.rights; // Add user rights flags to the message - command.consent = 0; - if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags - if (typeof mesh.consent == 'number') { command.consent |= mesh.consent; } // Add device group user consent - if (typeof node.consent == 'number') { command.consent |= node.consent; } // Add node user consent - if (typeof user.consent == 'number') { command.consent |= user.consent; } // Add user consent - command.username = user.name; // Add user name - if (typeof domain.desktopprivacybartext == 'string') { command.privacybartext = domain.desktopprivacybartext; } // Privacy bar text - delete command.nodeid; // Remove the nodeid since it's implyed. - agent.send(JSON.stringify(command)); - return true; - } - }); + rights = parent.GetNodeRights(user, agent.dbMeshKey, agent.dbNodeKey); + mesh = parent.meshes[agent.dbMeshKey]; + if ((rights != null) && (mesh != null) || ((rights & 16) != 0)) { // TODO: 16 is console permission, may need more gradular permission checking + if (ws.sessionId) { command.sessionid = ws.sessionId; } // Set the session id, required for responses. + command.rights = rights.rights; // Add user rights flags to the message + command.consent = mesh.consent; // Add user consent + if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags + command.username = user.name; // Add user name + if (typeof domain.desktopprivacybartext == 'string') { command.privacybartext = domain.desktopprivacybartext; } // Privacy bar text + delete command.nodeid; // Remove the nodeid since it's implyed. + agent.send(JSON.stringify(command)); + return true; + } } else { // Check if a peer server is connected to this agent var routing = parent.parent.GetRoutingServerId(command.nodeid, 1); // 1 = MeshAgent routing type if (routing != null) { // Check if we have permission to send a message to that node - parent.GetNodeWithRights(domain, user, agent.dbNodeKey, function (node, rights, visible) { - mesh = parent.meshes[routing.meshid]; - if ((node != null) && (rights != null) && (mesh != null) || ((rights & 16) != 0)) { // TODO: 16 is console permission, may need more gradular permission checking - if (ws.sessionId) { command.fromSessionid = ws.sessionId; } // Set the session id, required for responses. - command.rights = rights.rights; // Add user rights flags to the message - command.consent = 0; - if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags - if (typeof mesh.consent == 'number') { command.consent |= mesh.consent; } // Add device group user consent - if (typeof node.consent == 'number') { command.consent |= node.consent; } // Add node user consent - if (typeof user.consent == 'number') { command.consent |= user.consent; } // Add user consent - command.username = user.name; // Add user name - if (typeof domain.desktopprivacybartext == 'string') { command.privacybartext = domain.desktopprivacybartext; } // Privacy bar text - parent.parent.multiServer.DispatchMessageSingleServer(command, routing.serverid); - return true; - } - }); + rights = parent.GetNodeRights(user, routing.meshid, command.nodeid); + mesh = parent.meshes[routing.meshid]; + if (rights != null || ((rights & 16) != 0)) { // TODO: 16 is console permission, may need more gradular permission checking + if (ws.sessionId) { command.fromSessionid = ws.sessionId; } // Set the session id, required for responses. + command.rights = rights.rights; // Add user rights flags to the message + command.consent = mesh.consent; // Add user consent + if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags + command.username = user.name; // Add user name + if (typeof domain.desktopprivacybartext == 'string') { command.privacybartext = domain.desktopprivacybartext; } // Privacy bar text + parent.parent.multiServer.DispatchMessageSingleServer(command, routing.serverid); + return true; + } } } } diff --git a/package.json b/package.json index 1fcd507f..0d941e91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.5.1-q", + "version": "0.5.1-r", "keywords": [ "Remote Management", "Intel AMT", diff --git a/views/default.handlebars b/views/default.handlebars index e178eced..6692398a 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -2715,7 +2715,7 @@ } } - // Go tot he correct starting view page + // Go to the correct starting view page function gotoStartViewPage() { if (xxcurrentView != -1) return; if ('{{currentNode}}' != '') { @@ -2736,7 +2736,7 @@ go(parseInt('{{viewmode}}')); goBackStack.push(4); } else if (args.gotougrp != null) { - if (usergroups['ugrp/' + domain + '/' + args.gotougrp] == null) return; // This user group is not loaded yet + if ((usergroups == null) || usergroups['ugrp/' + domain + '/' + args.gotougrp] == null) return; // This user group is not loaded yet gotoUserGroup('ugrp/' + domain + '/' + args.gotougrp); go(parseInt('{{viewmode}}')); goBackStack.push(50); @@ -4812,15 +4812,7 @@ // Attribute: Host if ((features & 1) == 0) { // If not WAN-only, local hostname is in use - if ((meshrights & 4) != 0) { - if (node.host) { - x += addDeviceAttribute("Hostname", '' + EscapeHtml(node.host) + ''); - } else { - x += addDeviceAttribute("Hostname", '' + "None" + ''); - } - } else { - x += addDeviceAttribute("Hostname", EscapeHtml(node.host)); - } + x += addDeviceAttribute("Hostname", addLinkConditional('' + (node.host?EscapeHtml(node.host):('' + "None" + '')) + '', 'showEditNodeValueDialog(1)', meshrights & 4)); } // Attribute: Description @@ -8583,7 +8575,7 @@ var y = ''; for (var i in meshes) { if ((currentUserGroup.links == null) || (currentUserGroup.links[i] == null)) { y += ''; } } x += addHtmlValue("Device Group", '
'); - } else if (userid === 4) { + } else if ((userid === 4) || (userid == 7)) { var y = '', selectedMeshId = null, selectedNode = null; if (selected != null) { selectedNode = getNodeFromId(decodeURIComponent(selected)); if (selectedNode != null) { selectedMeshId = selectedNode.meshid; } } for (var i in meshes) { @@ -8591,10 +8583,10 @@ if (selectedMeshId == null) { selectedMeshId = meshes[i]._id; } y += ''; } } - x += addHtmlValue("Device Group", '
'); + x += addHtmlValue("Device Group", '
'); y = ''; for (var i in nodes) { if (nodes[i].meshid == selectedMeshId) { y += ''; } } - x += addHtmlValue("Device", '
'); + x += addHtmlValue("Device", '
'); } else { userid = decodeURIComponent(userid); var uname = userid.split('/')[2]; @@ -8608,7 +8600,7 @@ } } x += '
'; - if ((userid != 4) && (userid != 5) && (userid != 6)) { + if ((userid != 4) && (userid != 5) && (userid != 6) && (userid != 7)) { x += '
'; x += '
'; x += '
'; @@ -8642,6 +8634,11 @@ setDialogMode(2, (selected == null)?"Add Device Permissions":"Edit Device Permissions", 3, p20showAddMeshUserDialogEx, x, userid); QE('dp2meshid', selected == null); QE('dp2nodeid', selected == null); + } else if (userid === 7) { + console.log('a1'); + setDialogMode(2, (selected == null)?"Add Device Permissions":"Edit Device Permissions", 3, p20showAddMeshUserDialogEx, x, userid); + QE('dp2meshid', selected == null); + QE('dp2nodeid', selected == null); } else if (userid === 5) { setDialogMode(2, selected?"Edit User Device Permissions":"Add User Device Permissions", 3, p20showAddMeshUserDialogEx, x, userid); if (selected != null) { @@ -8742,6 +8739,7 @@ } function p20validateAddMeshUserDialog(updateId) { + console.log('p20validateAddMeshUserDialog', updateId); var ok = true; if (updateId === 4) { @@ -8871,6 +8869,9 @@ } else if (t === 6) { var ugrpid = decodeURIComponent(Q('dp2groupid').value); if (currentNode != null) { meshserver.send({ action: 'adddeviceuser', nodeid: currentNode._id, nodename: currentNode.name, userids: [ ugrpid ], rights: meshadmin }); } + } else if (t === 7) { + var nodeid = decodeURIComponent(Q('dp2nodeid').value), node = getNodeFromId(nodeid); + if (node != null) { meshserver.send({ action: 'adddeviceuser', nodeid: nodeid, nodename: node.name, userids: [ currentGroup._id ], rights: meshadmin }); } } else { if (t == null) { var users = Q('dp20username').value.split(','), users2 = []; @@ -10180,10 +10181,8 @@ x += ''; count = 1; - //var deviceGroupCount = 0, newDeviceGroup = false; - //for (var i in meshes) { deviceGroupCount++; if ((currentUserGroup.links == null) || (currentUserGroup.links[i] == null)) { newDeviceGroup = true; } } - //if ((deviceGroupCount > 0) && (newDeviceGroup)) { x += ' ' + "Add Device Group" + ''; } - x += '
'; + x += '
' + "Add Device" + ''; + x += '
' + "Common Devices" + '
'; if (currentUserGroup.links) { for (var i in currentUserGroup.links) { if (i.startsWith('node/')) {
' + "Common Devices" + '