mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-09-11 08:55:32 +03:00
Fixed web relay connection issue.
This commit is contained in:
parent
110cf49b48
commit
cbabfab7de
@ -1069,7 +1069,7 @@ function CreateMeshCentralServer(config, args) {
|
||||
}
|
||||
|
||||
// Start plugin manager if configuration allows this.
|
||||
if ((obj.config) && (obj.config.settings) && (obj.config.settings.plugins != null)) {
|
||||
if ((obj.config) && (obj.config.settings) && (obj.config.settings.plugins != null) && (obj.config.settings.plugins != false) && ((typeof obj.config.settings.plugins != 'object') || (obj.config.settings.plugins.enabled != false))) {
|
||||
const nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
|
||||
if (nodeVersion < 7) {
|
||||
addServerWarning("Plugin support requires Node v7.x or higher.");
|
||||
|
21
meshuser.js
21
meshuser.js
@ -2737,6 +2737,27 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
db.Remove('ra' + node._id); // Remove real agent to diagnostic agent link
|
||||
});
|
||||
|
||||
// Remove any user node links
|
||||
if (node.links != null) {
|
||||
for (var i in node.links) {
|
||||
if (i.startsWith('user/')) {
|
||||
var cuser = parent.users[i];
|
||||
if ((cuser != null) && (cuser.links != null) && (cuser.links[node._id] != null)) {
|
||||
// Remove the user link & save the user
|
||||
delete cuser.links[node._id];
|
||||
if (Object.keys(cuser.links).length == 0) { delete cuser.links; }
|
||||
db.SetUser(cuser);
|
||||
|
||||
// Notify user change
|
||||
var targets = ['*', 'server-users', cuser._id];
|
||||
var event = { etype: 'user', userid: cuser._id, username: cuser.name, action: 'accountchange', msg: 'Removed user device rights for ' + cuser.name, domain: domain.id, account: parent.CloneSafeUser(cuser) };
|
||||
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
|
||||
parent.parent.DispatchEvent(targets, obj, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Event node deletion
|
||||
var event = { etype: 'node', userid: user._id, username: user.name, action: 'removenode', nodeid: node._id, msg: 'Removed device ' + node.name + ' from group ' + parent.meshes[node.meshid].name, domain: domain.id };
|
||||
// TODO: We can't use the changeStream for node delete because we will not know the meshid the device was in.
|
||||
|
@ -73,7 +73,7 @@
|
||||
},
|
||||
"__MaxInvalidLogin": "Time in minutes, max amount of bad logins from a source IP in the time before logins are rejected.",
|
||||
"MaxInvalidLogin": { "time": 10, "count": 10, "coolofftime": 10 },
|
||||
"_Plugins": {
|
||||
"Plugins": {
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10231,16 +10231,20 @@
|
||||
x += '<a href=# onclick="return p20showAddMeshUserDialog(4)" style=cursor:pointer;margin-right:10px><img src=images/icon-addnew.png border=0 height=12 width=12> ' + "Add Device" + '</a>';
|
||||
x += '<table style="color:black;background-color:#EEE;border-color:#AAA;border-width:1px;border-style:solid;border-collapse:collapse" border=0 cellpadding=2 cellspacing=0 width=100%><tbody><tr style=background-color:#AAAAAA;font-weight:bold><th scope=col style=text-align:left;width:430px>' + "Common Devices" + '</th><th scope=col style=text-align:left></th></tr>';
|
||||
if (currentUser.links) {
|
||||
for (var i in currentUser.links) {
|
||||
if (i.startsWith('node/')) {
|
||||
var r = currentUser.links[i].rights, node = getNodeFromId(i), trash = '', rights = "Partial Device Rights", cr = GetNodeRights(node);
|
||||
if (node == null) { continue; }
|
||||
if ((userinfo.links) && (userinfo.links[i] != null) && (userinfo.links[i].rights != null)) { cr = userinfo.links[i].rights; }
|
||||
var nodename = node?EscapeHtml(node.name):('<i>' + "Unknown Device" + '</i>');
|
||||
if (r == 0xFFFFFFFF) rights = "Full Device Rights"; else if (r == 0) rights = "No Rights";
|
||||
if ((currentUser._id != userinfo._id) && ((cr & 2) != 0)) { trash = '<a href=# onclick=\'return p30removeNodeFromUser(event,"' + encodeURIComponent(node._id) + '")\' title=\"' + "Remove user rights to this device group" + '\" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>'; }
|
||||
x += '<tr ' + (((++count % 2) == 0) ? 'style=background-color:#DDD' : '') + '><td><div style=cursor:pointer onclick=p20showAddMeshUserDialog(4,\"' + encodeURIComponent(node._id) + '\")><div title=\"' + "Device" + '\" class=si' + node.icon + '></div><div> ' + nodename + '<div></div></div></td><td><div style=float:right>' + trash + '</div><div>' + rights + '</div></div></td></tr>';
|
||||
// Sort the list of devices to display
|
||||
var nodelist = [];
|
||||
for (var i in currentUser.links) { if (i.startsWith('node/')) { var node = getNodeFromId(i); if (node != null) { nodelist.push(node); } } }
|
||||
nodelist.sort(nameSort);
|
||||
for (var i in nodelist) {
|
||||
var node = nodelist[i], r = currentUser.links[node._id].rights, trash = '', rights = "Partial Device Rights", cr = GetNodeRights(node);
|
||||
if ((userinfo.links) && (userinfo.links[i] != null) && (userinfo.links[i].rights != null)) { cr = userinfo.links[i].rights; }
|
||||
var nodename = node?EscapeHtml(node.name):('<i>' + "Unknown Device" + '</i>');
|
||||
if (r == 0xFFFFFFFF) rights = "Full Device Rights"; else if (r == 0) rights = "No Rights";
|
||||
if ((cr & 2) != 0) {
|
||||
rights = '<div style=cursor:pointer onclick=p20showAddMeshUserDialog(4,\"' + encodeURIComponent(node._id) + '\")>' + rights + ' <img class=hoverButton style=cursor:pointer src=images/link5.png></div>';
|
||||
trash = '<a href=# onclick=\'return p30removeNodeFromUser(event,"' + encodeURIComponent(node._id) + '")\' title=\"' + "Remove user rights to this device group" + '\" style=cursor:pointer><img src=images/trash.png border=0 height=10 width=10></a>';
|
||||
}
|
||||
x += '<tr ' + (((++count % 2) == 0) ? 'style=background-color:#DDD' : '') + '><td><div title=\"' + "Device" + '\" class=si' + node.icon + '></div><div> ' + nodename + '<div></div></div></td><td><div style=float:right>' + trash + '</div><div>' + rights + '</div></td></tr>';
|
||||
}
|
||||
}
|
||||
if (count == 1) { x += '<tr><td><div style=padding:6px> <i>' + "No devices in common" + '</i><div></div></div></td><td></td></tr>'; }
|
||||
|
@ -3810,7 +3810,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
||||
var domain = null;
|
||||
if (noAuthOk == true) {
|
||||
domain = getDomain(req);
|
||||
try { ws.send(JSON.stringify({ action: 'close', cause: 'noauth', msg: 'noauth-1' })); ws.close(); return; } catch (e) { return; }
|
||||
if (domain == null) { try { ws.send(JSON.stringify({ action: 'close', cause: 'noauth', msg: 'noauth-1' })); ws.close(); return; } catch (e) { } return; }
|
||||
} else {
|
||||
// If authentication is required, enforce IP address filtering.
|
||||
domain = checkUserIpAddress(ws, req);
|
||||
|
Loading…
Reference in New Issue
Block a user