Fixed user and user group permissions not updating in web page.

This commit is contained in:
Ylian Saint-Hilaire 2020-02-10 16:36:03 -08:00
parent d19a88ddc5
commit b0e882bfaa
5 changed files with 61 additions and 30 deletions

View File

@ -2838,6 +2838,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (command.tcpaddr) { cookieContent.tcpaddr = command.tcpaddr; } // Indicates the browser want to agent to TCP connect to a remote address
if (command.tcpport) { cookieContent.tcpport = command.tcpport; } // Indicates the browser want to agent to TCP connect to a remote port
command.cookie = parent.parent.encodeCookie(cookieContent, parent.parent.loginCookieEncryptionKey);
command.trustedCert = parent.isTrustedCert(domain);
try { ws.send(JSON.stringify(command)); } catch (ex) { }
}
}

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.4.8-x",
"version": "0.4.8-z",
"keywords": [
"Remote Management",
"Intel AMT",

View File

@ -20955,4 +20955,4 @@
]
}
]
}
}

View File

@ -750,6 +750,7 @@
case 'users': {
users = {};
for (var m in message.users) { users[message.users[m]._id] = message.users[m]; }
if (currentUser != null) { currentUser = users[currentUser._id]; }
updateUsers();
break;
}
@ -761,6 +762,7 @@
case 'meshes': {
meshes = {};
for (var m in message.meshes) { meshes[message.meshes[m]._id] = message.meshes[m]; }
if (currentMesh != null) { currentMesh = meshes[currentMesh._id]; }
updateMeshes();
updateDevices();
break;

View File

@ -1640,6 +1640,7 @@
if (updateNaggleFlags & 16384) { updateUsers(); }
updateNaggleTimer = null;
updateNaggleFlags = 0;
gotoStartViewPage();
}, 150);
}
}
@ -1755,6 +1756,7 @@
case 'users': {
users = {};
for (var m in message.users) { users[message.users[m]._id] = message.users[m]; }
if (currentUser != null) { currentUser = users[currentUser._id]; }
masterUpdate(16384);
break;
}
@ -1766,6 +1768,7 @@
case 'meshes': {
meshes = {};
for (var m in message.meshes) { meshes[message.meshes[m]._id] = message.meshes[m]; }
if (currentMesh != null) { currentMesh = meshes[currentMesh._id]; }
masterUpdate(4 + 128);
break;
}
@ -1808,29 +1811,6 @@
}
}
masterUpdate(1 | 2 | 4 | 64);
if (xxcurrentView == -1) { if ('{{viewmode}}' != '') { go(parseInt('{{viewmode}}')); } else { setDialogMode(0); go(1); } }
if ('{{currentNode}}' != '') { gotoDevice('{{currentNode}}', parseInt('{{viewmode}}'));}
else if (args.gotonode != null) {
goBackStack.push(1);
gotoDevice('node/' + domain + '/' + args.gotonode, parseInt('{{viewmode}}'));
} else if (args.gotomesh != null) {
goBackStack.push(2);
gotoMesh('mesh/' + domain + '/' + args.gotomesh);
go(parseInt('{{viewmode}}'));
} else if (args.gotouser != null) {
goBackStack.push(4);
gotoUser('user/' + domain + '/' + args.gotouser);
go(parseInt('{{viewmode}}'));
} else if (args.gotougrp != null) {
goBackStack.push(50);
gotoUserGroup('ugrp/' + domain + '/' + args.gotougrp);
go(parseInt('{{viewmode}}'));
}
delete args.gotonode;
delete args.gotomesh;
delete args.gotouser;
delete args.gotougrp;
break;
}
case 'powertimeline': {
@ -2067,10 +2047,18 @@
}
case 'getcookie': {
if (message.tag == 'clickonce') {
var basicPort = '{{{serverRedirPort}}}' == '' ? '{{{serverPublicPort}}}' : '{{{serverRedirPort}}}';
var rdpurl = 'http://' + window.location.hostname + ':' + basicPort + '/clickonce/minirouter/MeshMiniRouter.application?WS=wss%3A%2F%2F' + window.location.hostname + '%2Fmeshrelay.ashx%3Fauth=' + message.cookie + '&CH={{{webcerthash}}}&AP=' + message.protocol + ((debugmode == 1) ? '' : '&HOL=1');
var newWindow = window.open(rdpurl, '_blank');
newWindow.opener = null;
if (message.trustedCert == true) {
// Trusted certificate, use HTTPS port.
var rdpurl = window.location.origin + domainUrl + 'clickonce/minirouter/MeshMiniRouter.application?WS=wss%3A%2F%2F' + window.location.hostname + '%2Fmeshrelay.ashx%3Fauth=' + message.cookie + '&CH={{{webcerthash}}}&AP=' + message.protocol + ((debugmode == 1) ? '' : '&HOL=1');
var newWindow = window.open(rdpurl, '_blank');
newWindow.opener = null;
} else {
// Not a trusted certificate, use HTTP port.
var basicPort = '{{{serverRedirPort}}}' == '' ? '{{{serverPublicPort}}}' : '{{{serverRedirPort}}}';
var rdpurl = 'http://' + window.location.hostname + ':' + basicPort + domainUrl + 'clickonce/minirouter/MeshMiniRouter.application?WS=wss%3A%2F%2F' + window.location.hostname + '%2Fmeshrelay.ashx%3Fauth=' + message.cookie + '&CH={{{webcerthash}}}&AP=' + message.protocol + ((debugmode == 1) ? '' : '&HOL=1');
var newWindow = window.open(rdpurl, '_blank');
newWindow.opener = null;
}
}
break;
}
@ -2315,7 +2303,9 @@
// Group update, refresh all our device groups and nodes. TODO: Optimize this to only do this when needed.
meshserver.send({ action: 'meshes' });
meshserver.send({ action: 'nodes' });
//meshserver.send({ action: 'nodes' });
//meshserver.send({ action: 'usergroups' });
//meshserver.send({ action: 'users' });
break;
}
case 'deleteusergroup': {
@ -2749,6 +2739,43 @@
}
}
// Go tot he correct starting view page
function gotoStartViewPage() {
if (xxcurrentView != -1) return;
if ('{{currentNode}}' != '') {
if (getNodeFromId('{{currentNode}}') == null) return; // This node is not loaded yet
gotoDevice('{{currentNode}}', parseInt('{{viewmode}}'));
} else if (args.gotonode != null) {
if (getNodeFromId('node/' + domain + '/' + args.gotonode) == null) return; // This node is not loaded yet
gotoDevice('node/' + domain + '/' + args.gotonode, parseInt('{{viewmode}}'));
goBackStack.push(1);
} else if (args.gotomesh != null) {
if (meshes['mesh/' + domain + '/' + args.gotomesh] == null) return; // This device group is not loaded yet
gotoMesh('mesh/' + domain + '/' + args.gotomesh);
go(parseInt('{{viewmode}}'));
goBackStack.push(2);
} else if (args.gotouser != null) {
if (users['user/' + domain + '/' + args.gotouser] == null) return; // This user is not loaded yet
gotoUser('user/' + domain + '/' + args.gotouser);
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
gotoUserGroup('ugrp/' + domain + '/' + args.gotougrp);
go(parseInt('{{viewmode}}'));
goBackStack.push(50);
} else if ('{{viewmode}}' != '') {
go(parseInt('{{viewmode}}'));
} else {
setDialogMode(0);
go(1);
}
delete args.gotonode;
delete args.gotomesh;
delete args.gotouser;
delete args.gotougrp;
}
//
// MY DEVICES
//
@ -4738,6 +4765,7 @@
//disconnectAllKvmFunction();
var node = getNodeFromId(nodeid);
if (node == null) return;
var mesh = meshes[node.meshid];
var meshrights = GetNodeRights(node);
if (!currentNode || currentNode._id != node._id || refresh == true) {