mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-09-11 08:55:32 +03:00
Updated MeshCommander and fixes to message dispatch.
This commit is contained in:
parent
a803af854b
commit
d443645423
4
db.js
4
db.js
@ -31,6 +31,7 @@ module.exports.CreateDB = function (parent, func) {
|
|||||||
var expireEventsSeconds = (60 * 60 * 24 * 20); // By default, expire events after 20 days. (Seconds * Minutes * Hours * Days)
|
var expireEventsSeconds = (60 * 60 * 24 * 20); // By default, expire events after 20 days. (Seconds * Minutes * Hours * Days)
|
||||||
var expirePowerEventsSeconds = (60 * 60 * 24 * 10); // By default, expire power events after 10 days. (Seconds * Minutes * Hours * Days)
|
var expirePowerEventsSeconds = (60 * 60 * 24 * 10); // By default, expire power events after 10 days. (Seconds * Minutes * Hours * Days)
|
||||||
var expireServerStatsSeconds = (60 * 60 * 24 * 30); // By default, expire power events after 30 days. (Seconds * Minutes * Hours * Days)
|
var expireServerStatsSeconds = (60 * 60 * 24 * 30); // By default, expire power events after 30 days. (Seconds * Minutes * Hours * Days)
|
||||||
|
const common = require('./common.js');
|
||||||
obj.identifier = null;
|
obj.identifier = null;
|
||||||
obj.dbKey = null;
|
obj.dbKey = null;
|
||||||
obj.changeStream = false;
|
obj.changeStream = false;
|
||||||
@ -851,6 +852,7 @@ module.exports.CreateDB = function (parent, func) {
|
|||||||
|
|
||||||
// Called when a device group has changed
|
// Called when a device group has changed
|
||||||
function dbMeshChange(meshChange, added) {
|
function dbMeshChange(meshChange, added) {
|
||||||
|
common.unEscapeLinksFieldName(meshChange.fullDocument);
|
||||||
const mesh = meshChange.fullDocument;
|
const mesh = meshChange.fullDocument;
|
||||||
|
|
||||||
// Update the mesh object in memory
|
// Update the mesh object in memory
|
||||||
@ -865,7 +867,7 @@ module.exports.CreateDB = function (parent, func) {
|
|||||||
delete mesh.type;
|
delete mesh.type;
|
||||||
delete mesh._id;
|
delete mesh._id;
|
||||||
if (mesh.amt) { delete mesh.amt.password; } // Remove the Intel AMT password if present
|
if (mesh.amt) { delete mesh.amt.password; } // Remove the Intel AMT password if present
|
||||||
parent.DispatchEvent(['*', mesh._id], obj, mesh);
|
parent.DispatchEvent(['*', mesh.meshid], obj, mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when a user account has changed
|
// Called when a user account has changed
|
||||||
|
103
meshuser.js
103
meshuser.js
@ -566,7 +566,14 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
case 'help': {
|
case 'help': {
|
||||||
r = 'Available commands: help, info, versions, args, resetserver, showconfig, usersessions, tasklimiter, setmaxtasks, cores,\r\n'
|
r = 'Available commands: help, info, versions, args, resetserver, showconfig, usersessions, tasklimiter, setmaxtasks, cores,\r\n'
|
||||||
r += 'migrationagents, agentstats, webstats, mpsstats, swarmstats, acceleratorsstats, updatecheck, serverupdate, nodeconfig,\r\n';
|
r += 'migrationagents, agentstats, webstats, mpsstats, swarmstats, acceleratorsstats, updatecheck, serverupdate, nodeconfig,\r\n';
|
||||||
r += 'heapdump, relays, autobackup, backupconfig, dupagents.';
|
r += 'heapdump, relays, autobackup, backupconfig, dupagents, dispatchtable.';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'dispatchtable': {
|
||||||
|
r = '';
|
||||||
|
for (var i in parent.parent.eventsDispatch) {
|
||||||
|
r += (i + ', ' + parent.parent.eventsDispatch[i].length + '\r\n');
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'dupagents': {
|
case 'dupagents': {
|
||||||
@ -972,7 +979,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
mesh = parent.meshes[meshid];
|
mesh = parent.meshes[meshid];
|
||||||
if (mesh) {
|
if (mesh) {
|
||||||
// Remove user from the mesh
|
// Remove user from the mesh
|
||||||
if (mesh.links[deluser._id] != null) { delete mesh.links[deluser._id]; parent.db.Set(mesh); }
|
if (mesh.links[deluser._id] != null) { delete mesh.links[deluser._id]; parent.db.Set(common.escapeLinksFieldName(mesh)); }
|
||||||
// Notify mesh change
|
// Notify mesh change
|
||||||
change = 'Removed user ' + deluser.name + ' from group ' + mesh.name;
|
change = 'Removed user ' + deluser.name + ' from group ' + mesh.name;
|
||||||
var event = { etype: 'mesh', username: user.name, userid: user._id, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: change, domain: domain.id };
|
var event = { etype: 'mesh', username: user.name, userid: user._id, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: change, domain: domain.id };
|
||||||
@ -1522,65 +1529,50 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
} catch (ex) { err = 'Validation exception: ' + ex; }
|
} catch (ex) { err = 'Validation exception: ' + ex; }
|
||||||
|
|
||||||
// Handle any errors
|
// Handle any errors
|
||||||
if (err != null) {
|
if (err != null) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deletemesh', responseid: command.responseid, result: err })); } catch (ex) { } } break; }
|
||||||
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deletemesh', responseid: command.responseid, result: err })); } catch (ex) { } }
|
|
||||||
break;
|
// Get the device group reference we are going to delete
|
||||||
|
var mesh = parent.meshes[command.meshid];
|
||||||
|
if (mesh == null) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deletemesh', responseid: command.responseid, result: 'Unknown device group' })); } catch (ex) { } } return; }
|
||||||
|
|
||||||
|
// Check if this user has rights to do this
|
||||||
|
var err = null;
|
||||||
|
if (mesh.links[user._id] == null || mesh.links[user._id].rights != 0xFFFFFFFF) { err = 'Access denied'; }
|
||||||
|
if ((command.meshid.split('/').length != 3) || (command.meshid.split('/')[1] != domain.id)) { err = 'Invalid group'; } // Invalid domain, operation only valid for current domain
|
||||||
|
|
||||||
|
// Handle any errors
|
||||||
|
if (err != null) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deletemesh', responseid: command.responseid, result: err })); } catch (ex) { } } return; }
|
||||||
|
|
||||||
|
// Fire the removal event first, because after this, the event will not route
|
||||||
|
var event = { etype: 'mesh', username: user.name, meshid: command.meshid, name: command.meshname, action: 'deletemesh', msg: 'Mesh deleted: ' + command.meshname, domain: domain.id };
|
||||||
|
parent.parent.DispatchEvent(['*', command.meshid], obj, event); // Even if DB change stream is active, this event need to be acted on.
|
||||||
|
|
||||||
|
// Remove all user links to this mesh
|
||||||
|
for (var j in mesh.links) {
|
||||||
|
var xuser = parent.users[j];
|
||||||
|
if (xuser && xuser.links) {
|
||||||
|
delete xuser.links[mesh._id];
|
||||||
|
db.SetUser(xuser);
|
||||||
|
parent.parent.DispatchEvent([xuser._id], obj, 'resubscribe');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
db.Get(command.meshid, function (err, meshes) {
|
// Delete all files on the server for this mesh
|
||||||
if (meshes.length != 1) {
|
try {
|
||||||
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deletemesh', responseid: command.responseid, result: 'Unknown device group' })); } catch (ex) { } }
|
var meshpath = parent.getServerRootFilePath(mesh);
|
||||||
return;
|
if (meshpath != null) { parent.deleteFolderRec(meshpath); }
|
||||||
}
|
} catch (e) { }
|
||||||
var mesh = common.unEscapeLinksFieldName(meshes[0]);
|
|
||||||
|
|
||||||
// Check if this user has rights to do this
|
parent.parent.RemoveEventDispatchId(command.meshid); // Remove all subscriptions to this mesh
|
||||||
var err = null;
|
|
||||||
if (mesh.links[user._id] == null || mesh.links[user._id].rights != 0xFFFFFFFF) { err = 'Access denied'; }
|
|
||||||
if ((command.meshid.split('/').length != 3) || (command.meshid.split('/')[1] != domain.id)) { err = 'Invalid group'; } // Invalid domain, operation only valid for current domain
|
|
||||||
|
|
||||||
// Handle any errors
|
// Mark the mesh as deleted
|
||||||
if (err != null) {
|
mesh.deleted = new Date(); // Mark the time this mesh was deleted, we can expire it at some point.
|
||||||
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deletemesh', responseid: command.responseid, result: err })); } catch (ex) { } }
|
db.Set(common.escapeLinksFieldName(mesh)); // We don't really delete meshes because if a device connects to is again, we will un-delete it.
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fire the removal event first, because after this, the event will not route
|
// Delete all devices attached to this mesh in the database
|
||||||
var event = { etype: 'mesh', username: user.name, meshid: command.meshid, name: command.meshname, action: 'deletemesh', msg: 'Mesh deleted: ' + command.meshname, domain: domain.id };
|
db.RemoveMeshDocuments(command.meshid);
|
||||||
parent.parent.DispatchEvent(['*', command.meshid], obj, event); // Even if DB change stream is active, this event need to be acted on.
|
|
||||||
|
|
||||||
// Remove all user links to this mesh
|
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deletemesh', responseid: command.responseid, result: 'ok' })); } catch (ex) { } }
|
||||||
for (i in meshes) {
|
|
||||||
var links = meshes[i].links;
|
|
||||||
for (var j in links) {
|
|
||||||
var xuser = parent.users[j];
|
|
||||||
if (xuser && xuser.links) {
|
|
||||||
delete xuser.links[meshes[i]._id];
|
|
||||||
db.SetUser(xuser);
|
|
||||||
parent.parent.DispatchEvent([xuser._id], obj, 'resubscribe');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete all files on the server for this mesh
|
|
||||||
try {
|
|
||||||
var meshpath = parent.getServerRootFilePath(mesh);
|
|
||||||
if (meshpath != null) { parent.deleteFolderRec(meshpath); }
|
|
||||||
} catch (e) { }
|
|
||||||
|
|
||||||
parent.parent.RemoveEventDispatchId(command.meshid); // Remove all subscriptions to this mesh
|
|
||||||
|
|
||||||
// Mark the mesh as deleted
|
|
||||||
var dbmesh = meshes[0];
|
|
||||||
dbmesh.deleted = new Date(); // Mark the time this mesh was deleted, we can expire it at some point.
|
|
||||||
db.Set(common.escapeLinksFieldName(mesh)); // We don't really delete meshes because if a device connects to is again, we will up-delete it.
|
|
||||||
parent.meshes[command.meshid] = mesh; // Update the mesh in memory;
|
|
||||||
|
|
||||||
// Delete all devices attached to this mesh in the database
|
|
||||||
db.RemoveMeshDocuments(command.meshid);
|
|
||||||
|
|
||||||
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deletemesh', responseid: command.responseid, result: 'ok' })); } catch (ex) { } }
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'editmesh':
|
case 'editmesh':
|
||||||
@ -1712,7 +1704,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
} else {
|
} else {
|
||||||
event = { etype: 'mesh', username: user.name, userid: (deluserid.split('/')[2]), meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Removed user ' + (deluserid.split('/')[2]) + ' from group ' + mesh.name, domain: domain.id };
|
event = { etype: 'mesh', username: user.name, userid: (deluserid.split('/')[2]), meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Removed user ' + (deluserid.split('/')[2]) + ' from group ' + mesh.name, domain: domain.id };
|
||||||
}
|
}
|
||||||
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.
|
|
||||||
parent.parent.DispatchEvent(['*', mesh._id, user._id, command.userid], obj, event);
|
parent.parent.DispatchEvent(['*', mesh._id, user._id, command.userid], obj, event);
|
||||||
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'removemeshuser', responseid: command.responseid, result: 'ok' })); } catch (ex) { } }
|
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'removemeshuser', responseid: command.responseid, result: 'ok' })); } catch (ex) { } }
|
||||||
} else {
|
} else {
|
||||||
|
1663
public/commander.htm
1663
public/commander.htm
File diff suppressed because one or more lines are too long
@ -49,9 +49,10 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) {
|
|||||||
obj.lastKeepAlive = Date.now();
|
obj.lastKeepAlive = Date.now();
|
||||||
// ###END###{DesktopInband}
|
// ###END###{DesktopInband}
|
||||||
|
|
||||||
// ###BEGIN###{DesktopFocus}
|
obj.mNagleTimer = null; // Mouse motion slowdown timer
|
||||||
obj.mx = 0; // Last mouse x position
|
obj.mx = 0; // Last mouse x position
|
||||||
obj.my = 0; // Last mouse y position
|
obj.my = 0; // Last mouse y position
|
||||||
|
// ###BEGIN###{DesktopFocus}
|
||||||
obj.ox = -1; // Old mouse x position
|
obj.ox = -1; // Old mouse x position
|
||||||
obj.oy = -1; // Old mouse y position
|
obj.oy = -1; // Old mouse y position
|
||||||
obj.focusmode = 0;
|
obj.focusmode = 0;
|
||||||
@ -836,10 +837,10 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) {
|
|||||||
|
|
||||||
// RFB "PointerEvent" and mouse handlers
|
// RFB "PointerEvent" and mouse handlers
|
||||||
obj.mousedblclick = function (e) { }
|
obj.mousedblclick = function (e) { }
|
||||||
obj.mousedown = function (e) { obj.buttonmask |= (1 << e.button); return obj.mousemove(e); }
|
obj.mousedown = function (e) { obj.buttonmask |= (1 << e.button); return obj.mousemove(e, 1); }
|
||||||
obj.mouseup = function (e) { obj.buttonmask &= (0xFFFF - (1 << e.button)); return obj.mousemove(e); }
|
obj.mouseup = function (e) { obj.buttonmask &= (0xFFFF - (1 << e.button)); return obj.mousemove(e, 1); }
|
||||||
obj.mousemove = function (e) {
|
obj.mousemove = function (e, force) {
|
||||||
if (obj.state != 4) return true;
|
if (obj.state < 4) return true;
|
||||||
var ScaleFactorHeight = (obj.canvas.canvas.height / Q(obj.canvasid).offsetHeight);
|
var ScaleFactorHeight = (obj.canvas.canvas.height / Q(obj.canvasid).offsetHeight);
|
||||||
var ScaleFactorWidth = (obj.canvas.canvas.width / Q(obj.canvasid).offsetWidth);
|
var ScaleFactorWidth = (obj.canvas.canvas.width / Q(obj.canvasid).offsetWidth);
|
||||||
var Offsets = obj.getPositionOfControl(Q(obj.canvasid));
|
var Offsets = obj.getPositionOfControl(Q(obj.canvasid));
|
||||||
@ -856,7 +857,18 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) {
|
|||||||
}
|
}
|
||||||
// ###END###{DesktopRotation}
|
// ###END###{DesktopRotation}
|
||||||
|
|
||||||
obj.send(String.fromCharCode(5, obj.buttonmask) + ShortToStr(obj.mx) + ShortToStr(obj.my));
|
// This is the mouse motion nagle timer. Slow down the mouse motion event rate.
|
||||||
|
if (force == 1) {
|
||||||
|
obj.send(String.fromCharCode(5, obj.buttonmask) + ShortToStr(obj.mx) + ShortToStr(obj.my));
|
||||||
|
if (obj.mNagleTimer != null) { clearTimeout(obj.mNagleTimer); obj.mNagleTimer = null; }
|
||||||
|
} else {
|
||||||
|
if (obj.mNagleTimer == null) {
|
||||||
|
obj.mNagleTimer = setTimeout(function () {
|
||||||
|
obj.send(String.fromCharCode(5, obj.buttonmask) + ShortToStr(obj.mx) + ShortToStr(obj.my));
|
||||||
|
obj.mNagleTimer = null;
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ###BEGIN###{DesktopFocus}
|
// ###BEGIN###{DesktopFocus}
|
||||||
// Update focus area if we are in focus mode
|
// Update focus area if we are in focus mode
|
||||||
|
@ -261,7 +261,7 @@ var CreateAmtRedirect = function (module, authCookie) {
|
|||||||
if (obj.debugmode == 1) { console.log('Send', x); }
|
if (obj.debugmode == 1) { console.log('Send', x); }
|
||||||
var b = new Uint8Array(x.length);
|
var b = new Uint8Array(x.length);
|
||||||
for (var i = 0; i < x.length; ++i) { b[i] = x.charCodeAt(i); }
|
for (var i = 0; i < x.length; ++i) { b[i] = x.charCodeAt(i); }
|
||||||
obj.socket.send(b.buffer);
|
try { obj.socket.send(b.buffer); } catch (ex) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
webserver.js
24
webserver.js
@ -1125,8 +1125,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||||||
var mesh = obj.meshes[meshid];
|
var mesh = obj.meshes[meshid];
|
||||||
if (mesh) {
|
if (mesh) {
|
||||||
// Remove user from the mesh
|
// Remove user from the mesh
|
||||||
var escUserId = obj.common.escapeFieldName(userid);
|
if (mesh.links[userid] != null) { delete mesh.links[userid]; obj.db.Set(obj.common.escapeLinksFieldName(mesh)); }
|
||||||
if (mesh.links[escUserId] != null) { delete mesh.links[escUserId]; obj.db.Set(mesh); }
|
|
||||||
// Notify mesh change
|
// Notify mesh change
|
||||||
var change = 'Removed user ' + user.name + ' from group ' + mesh.name;
|
var change = 'Removed user ' + user.name + ' from group ' + mesh.name;
|
||||||
obj.parent.DispatchEvent(['*', mesh._id, user._id, userid], obj, { etype: 'mesh', username: user.name, userid: userid, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: change, domain: domain.id });
|
obj.parent.DispatchEvent(['*', mesh._id, user._id, userid], obj, { etype: 'mesh', username: user.name, userid: userid, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: change, domain: domain.id });
|
||||||
@ -2529,7 +2528,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||||||
if (domain == null) { res.sendStatus(404); return; }
|
if (domain == null) { res.sendStatus(404); return; }
|
||||||
|
|
||||||
// If required, check if this user has rights to do this
|
// If required, check if this user has rights to do this
|
||||||
if ((obj.parent.config.settings != null) && (obj.parent.config.settings.lockagentdownload == true) && (req.session.userid == null)) { res.sendStatus(401); return; }
|
if ((obj.parent.config.settings != null) && ((obj.parent.config.settings.lockagentdownload == true) || (domain.lockagentdownload == true)) && (req.session.userid == null)) { res.sendStatus(401); return; }
|
||||||
|
|
||||||
if (req.query.id != null) {
|
if (req.query.id != null) {
|
||||||
// Send a specific mesh agent back
|
// Send a specific mesh agent back
|
||||||
@ -2545,10 +2544,9 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||||||
if (mesh == null) { res.sendStatus(401); return; }
|
if (mesh == null) { res.sendStatus(401); return; }
|
||||||
|
|
||||||
// If required, check if this user has rights to do this
|
// If required, check if this user has rights to do this
|
||||||
if ((obj.parent.config.settings != null) && (obj.parent.config.settings.lockagentdownload == true)) {
|
if ((obj.parent.config.settings != null) && ((obj.parent.config.settings.lockagentdownload == true) || (domain.lockagentdownload == true))) {
|
||||||
var user = obj.users[req.session.userid];
|
var user = obj.users[req.session.userid];
|
||||||
var escUserId = obj.common.escapeFieldName(user._id);
|
if ((user == null) || (mesh.links[user._id] == null) || ((mesh.links[user._id].rights & 1) == 0)) { res.sendStatus(401); return; }
|
||||||
if ((user == null) || (mesh.links[escUserId] == null) || ((mesh.links[escUserId].rights & 1) == 0)) { res.sendStatus(401); return; }
|
|
||||||
if (domain.id != mesh.domain) { res.sendStatus(401); return; }
|
if (domain.id != mesh.domain) { res.sendStatus(401); return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2690,7 +2688,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||||||
if ((domain == null) || (req.query.id == null)) { res.sendStatus(404); return; }
|
if ((domain == null) || (req.query.id == null)) { res.sendStatus(404); return; }
|
||||||
|
|
||||||
// If required, check if this user has rights to do this
|
// If required, check if this user has rights to do this
|
||||||
if ((obj.parent.config.settings != null) && (obj.parent.config.settings.lockagentdownload == true) && (req.session.userid == null)) { res.sendStatus(401); return; }
|
if ((obj.parent.config.settings != null) && ((obj.parent.config.settings.lockagentdownload == true) || (domain.lockagentdownload == true)) && (req.session.userid == null)) { res.sendStatus(401); return; }
|
||||||
|
|
||||||
// Send a specific mesh agent back
|
// Send a specific mesh agent back
|
||||||
var argentInfo = obj.parent.meshAgentBinaries[req.query.id];
|
var argentInfo = obj.parent.meshAgentBinaries[req.query.id];
|
||||||
@ -2702,10 +2700,9 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||||||
if (mesh == null) { res.sendStatus(401); return; }
|
if (mesh == null) { res.sendStatus(401); return; }
|
||||||
|
|
||||||
// If required, check if this user has rights to do this
|
// If required, check if this user has rights to do this
|
||||||
if ((obj.parent.config.settings != null) && (obj.parent.config.settings.lockagentdownload == true)) {
|
if ((obj.parent.config.settings != null) && ((obj.parent.config.settings.lockagentdownload == true) || (domain.lockagentdownload == true))) {
|
||||||
var user = obj.users[req.session.userid];
|
var user = obj.users[req.session.userid];
|
||||||
var escUserId = obj.common.escapeFieldName(user._id);
|
if ((user == null) || (mesh.links[user._id] == null) || ((mesh.links[user._id].rights & 1) == 0)) { res.sendStatus(401); return; }
|
||||||
if ((user == null) || (mesh.links[escUserId] == null) || ((mesh.links[escUserId].rights & 1) == 0)) { res.sendStatus(401); return; }
|
|
||||||
if (domain.id != mesh.domain) { res.sendStatus(401); return; }
|
if (domain.id != mesh.domain) { res.sendStatus(401); return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2785,17 +2782,16 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||||||
//if ((domain.id !== '') || (!req.session) || (req.session == null) || (!req.session.userid)) { res.sendStatus(401); return; }
|
//if ((domain.id !== '') || (!req.session) || (req.session == null) || (!req.session.userid)) { res.sendStatus(401); return; }
|
||||||
|
|
||||||
// If required, check if this user has rights to do this
|
// If required, check if this user has rights to do this
|
||||||
if ((obj.parent.config.settings != null) && (obj.parent.config.settings.lockagentdownload == true) && (req.session.userid == null)) { res.sendStatus(401); return; }
|
if ((obj.parent.config.settings != null) && ((obj.parent.config.settings.lockagentdownload == true) || (domain.lockagentdownload == true)) && (req.session.userid == null)) { res.sendStatus(401); return; }
|
||||||
|
|
||||||
// Fetch the mesh object
|
// Fetch the mesh object
|
||||||
var mesh = obj.meshes['mesh/' + domain.id + '/' + req.query.id];
|
var mesh = obj.meshes['mesh/' + domain.id + '/' + req.query.id];
|
||||||
if (mesh == null) { res.sendStatus(401); return; }
|
if (mesh == null) { res.sendStatus(401); return; }
|
||||||
|
|
||||||
// If needed, check if this user has rights to do this
|
// If needed, check if this user has rights to do this
|
||||||
if ((obj.parent.config.settings != null) && (obj.parent.config.settings.lockagentdownload == true)) {
|
if ((obj.parent.config.settings != null) && ((obj.parent.config.settings.lockagentdownload == true) || (domain.lockagentdownload == true))) {
|
||||||
var user = obj.users[req.session.userid];
|
var user = obj.users[req.session.userid];
|
||||||
var escUserId = obj.common.escapeFieldName(user._id);
|
if ((user == null) || (mesh.links[user._id] == null) || ((mesh.links[user._id].rights & 1) == 0)) { res.sendStatus(401); return; }
|
||||||
if ((user == null) || (mesh.links[escUserId] == null) || ((mesh.links[escUserId].rights & 1) == 0)) { res.sendStatus(401); return; }
|
|
||||||
if (domain.id != mesh.domain) { res.sendStatus(401); return; }
|
if (domain.id != mesh.domain) { res.sendStatus(401); return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user