Fixed install dependencies install, Device group incorrectly showing up on admin account.

Ylian Saint-Hilaire committed Jan 30, 2020 at 12:25 UTC 3eef0f3e71043c27d737d8e39c58bba86df46602
3 files changed +23 -7
meshcentral.js
+1 -1
@@ -2254,7 +2254,7 @@ function InstallModule(modulename, func, tag1, tag2) {
2254 // Get the working directory
2255 if ((__dirname.endsWith('/node_modules/meshcentral')) || (__dirname.endsWith('\\node_modules\\meshcentral')) || (__dirname.endsWith('/node_modules/meshcentral/')) || (__dirname.endsWith('\\node_modules\\meshcentral\\'))) { parentpath = require('path').join(__dirname, '../..'); }
2256
2257 - child_process.exec(`npm install --no-save --no-optional ${modulename}`, { maxBuffer: 512000, timeout: 120000, cwd: parentpath }, function (error, stdout, stderr) {
2257 + child_process.exec(`npm install --no-optional ${modulename}`, { maxBuffer: 512000, timeout: 120000, cwd: parentpath }, function (error, stdout, stderr) {
2258 if ((error != null) && (error != '')) {
2259 console.log('ERROR: Unable to install required module "' + modulename + '". MeshCentral may not have access to npm, or npm may not have suffisent rights to load the new module. Try "npm install ' + modulename + '" to manualy install this module.\r\n');
2260 process.exit();
views/default-mobile.handlebars
+11 -3
@@ -945,9 +945,17 @@
945 case 'meshchange': {
946 // Update mesh information
947 if (meshes[message.event.meshid] == null) {
948 + // Check if we have any access to this device group
949 + var add = false;
950 + if (message.event.links[userinfo._id] != null) { add = true; }
951 + if (userinfo.links[message.event.meshid] != null) { add = true; }
952 + for (var i in userinfo.links) { if ((i.startsWith('ugrp/')) && (message.event.links[i] != null)) { add = true; } }
953 +
954 // This is a new mesh for us
949 - meshes[message.event.meshid] = { _id: message.event.meshid, name: message.event.name, mtype: message.event.mtype, desc: message.event.desc, links: message.event.links };
950 - meshserver.send({ action: 'nodes' }); // Request a refresh of all nodes (TODO: We could optimize this to only request nodes for the new mesh).
955 + if (add) {
956 + meshes[message.event.meshid] = { _id: message.event.meshid, name: message.event.name, mtype: message.event.mtype, desc: message.event.desc, links: message.event.links };
957 + meshserver.send({ action: 'nodes' }); // Request a refresh of all nodes (TODO: We could optimize this to only request nodes for the new mesh).
958 + }
959 } else {
960 // This is an existing mesh
961 if (meshes[message.event.meshid].name != message.event.name) {
@@ -3477,7 +3485,7 @@
3485 }
3486 }
3487
3480 - return rights;
3488 + return false;
3489 }
3490
3491 // Return the user rights for a given node
views/default.handlebars
+11 -3
@@ -2314,9 +2314,17 @@
2314 case 'meshchange': {
2315 // Update mesh information
2316 if (meshes[message.event.meshid] == null) {
2317 + // Check if we have any access to this device group
2318 + var add = false;
2319 + if (message.event.links[userinfo._id] != null) { add = true; }
2320 + if (userinfo.links[message.event.meshid] != null) { add = true; }
2321 + for (var i in userinfo.links) { if ((i.startsWith('ugrp/')) && (message.event.links[i] != null)) { add = true; } }
2322 +
2323 // This is a new mesh for us
2318 - meshes[message.event.meshid] = { _id: message.event.meshid, name: message.event.name, mtype: message.event.mtype, desc: message.event.desc, links: message.event.links };
2319 - meshserver.send({ action: 'nodes' }); // Request a refresh of all nodes (TODO: We could optimize this to only request nodes for the new mesh).
2324 + if (add) {
2325 + meshes[message.event.meshid] = { _id: message.event.meshid, name: message.event.name, mtype: message.event.mtype, desc: message.event.desc, links: message.event.links };
2326 + meshserver.send({ action: 'nodes' }); // Request a refresh of all nodes (TODO: We could optimize this to only request nodes for the new mesh).
2327 + }
2328 } else {
2329 // This is an existing mesh
2330 if (message.event.name != null) {
@@ -10720,7 +10728,7 @@
10728 }
10729 }
10730
10723 - return rights;
10731 + return false;
10732 }
10733
10734 // Return the user rights for a given node