Fixed user and user group permissions not updating in web page.
Ylian Saint-Hilaire committed
Feb 10, 2020 at 16:36 UTC
b0e882bfaa2275cb07ea4058d735d52729783a8c
5 files changed
+61
-30
meshuser.js
+1
@@ -2838,6 +2838,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2838
if (command.tcpaddr) { cookieContent.tcpaddr = command.tcpaddr; } // Indicates the browser want to agent to TCP connect to a remote address
2839
if (command.tcpport) { cookieContent.tcpport = command.tcpport; } // Indicates the browser want to agent to TCP connect to a remote port
2840
command.cookie = parent.parent.encodeCookie(cookieContent, parent.parent.loginCookieEncryptionKey);
2841
+ command.trustedCert = parent.isTrustedCert(domain);
2842
try { ws.send(JSON.stringify(command)); } catch (ex) { }
2843
}
2844
}
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.4.8-x",
3
+ "version": "0.4.8-z",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
translate/translate.json
+1
-1
@@ -20955,4 +20955,4 @@
20955
]
20956
}
20957
]
20958
-}
20958
+}
\ No newline at end of file
views/default-mobile.handlebars
+2
@@ -750,6 +750,7 @@
750
case 'users': {
751
users = {};
752
for (var m in message.users) { users[message.users[m]._id] = message.users[m]; }
753
+ if (currentUser != null) { currentUser = users[currentUser._id]; }
754
updateUsers();
755
break;
756
}
@@ -761,6 +762,7 @@
762
case 'meshes': {
763
meshes = {};
764
for (var m in message.meshes) { meshes[message.meshes[m]._id] = message.meshes[m]; }
765
+ if (currentMesh != null) { currentMesh = meshes[currentMesh._id]; }
766
updateMeshes();
767
updateDevices();
768
break;
views/default.handlebars
+56
-28
@@ -1640,6 +1640,7 @@
1640
if (updateNaggleFlags & 16384) { updateUsers(); }
1641
updateNaggleTimer = null;
1642
updateNaggleFlags = 0;
1643
+ gotoStartViewPage();
1644
}, 150);
1645
}
1646
}
@@ -1755,6 +1756,7 @@
1756
case 'users': {
1757
users = {};
1758
for (var m in message.users) { users[message.users[m]._id] = message.users[m]; }
1759
+ if (currentUser != null) { currentUser = users[currentUser._id]; }
1760
masterUpdate(16384);
1761
break;
1762
}
@@ -1766,6 +1768,7 @@
1768
case 'meshes': {
1769
meshes = {};
1770
for (var m in message.meshes) { meshes[message.meshes[m]._id] = message.meshes[m]; }
1771
+ if (currentMesh != null) { currentMesh = meshes[currentMesh._id]; }
1772
masterUpdate(4 + 128);
1773
break;
1774
}
@@ -1808,29 +1811,6 @@
1811
}
1812
}
1813
masterUpdate(1 | 2 | 4 | 64);
1811
-
1812
- if (xxcurrentView == -1) { if ('{{viewmode}}' != '') { go(parseInt('{{viewmode}}')); } else { setDialogMode(0); go(1); } }
1813
- if ('{{currentNode}}' != '') { gotoDevice('{{currentNode}}', parseInt('{{viewmode}}'));}
1814
- else if (args.gotonode != null) {
1815
- goBackStack.push(1);
1816
- gotoDevice('node/' + domain + '/' + args.gotonode, parseInt('{{viewmode}}'));
1817
- } else if (args.gotomesh != null) {
1818
- goBackStack.push(2);
1819
- gotoMesh('mesh/' + domain + '/' + args.gotomesh);
1820
- go(parseInt('{{viewmode}}'));
1821
- } else if (args.gotouser != null) {
1822
- goBackStack.push(4);
1823
- gotoUser('user/' + domain + '/' + args.gotouser);
1824
- go(parseInt('{{viewmode}}'));
1825
- } else if (args.gotougrp != null) {
1826
- goBackStack.push(50);
1827
- gotoUserGroup('ugrp/' + domain + '/' + args.gotougrp);
1828
- go(parseInt('{{viewmode}}'));
1829
- }
1830
- delete args.gotonode;
1831
- delete args.gotomesh;
1832
- delete args.gotouser;
1833
- delete args.gotougrp;
1814
break;
1815
}
1816
case 'powertimeline': {
@@ -2067,10 +2047,18 @@
2047
}
2048
case 'getcookie': {
2049
if (message.tag == 'clickonce') {
2070
- var basicPort = '{{{serverRedirPort}}}' == '' ? '{{{serverPublicPort}}}' : '{{{serverRedirPort}}}';
2071
- 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');
2072
- var newWindow = window.open(rdpurl, '_blank');
2073
- newWindow.opener = null;
2050
+ if (message.trustedCert == true) {
2051
+ // Trusted certificate, use HTTPS port.
2052
+ 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');
2053
+ var newWindow = window.open(rdpurl, '_blank');
2054
+ newWindow.opener = null;
2055
+ } else {
2056
+ // Not a trusted certificate, use HTTP port.
2057
+ var basicPort = '{{{serverRedirPort}}}' == '' ? '{{{serverPublicPort}}}' : '{{{serverRedirPort}}}';
2058
+ 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');
2059
+ var newWindow = window.open(rdpurl, '_blank');
2060
+ newWindow.opener = null;
2061
+ }
2062
}
2063
break;
2064
}
@@ -2315,7 +2303,9 @@
2303
2304
// Group update, refresh all our device groups and nodes. TODO: Optimize this to only do this when needed.
2305
meshserver.send({ action: 'meshes' });
2318
- meshserver.send({ action: 'nodes' });
2306
+ //meshserver.send({ action: 'nodes' });
2307
+ //meshserver.send({ action: 'usergroups' });
2308
+ //meshserver.send({ action: 'users' });
2309
break;
2310
}
2311
case 'deleteusergroup': {
@@ -2749,6 +2739,43 @@
2739
}
2740
}
2741
2742
+ // Go tot he correct starting view page
2743
+ function gotoStartViewPage() {
2744
+ if (xxcurrentView != -1) return;
2745
+ if ('{{currentNode}}' != '') {
2746
+ if (getNodeFromId('{{currentNode}}') == null) return; // This node is not loaded yet
2747
+ gotoDevice('{{currentNode}}', parseInt('{{viewmode}}'));
2748
+ } else if (args.gotonode != null) {
2749
+ if (getNodeFromId('node/' + domain + '/' + args.gotonode) == null) return; // This node is not loaded yet
2750
+ gotoDevice('node/' + domain + '/' + args.gotonode, parseInt('{{viewmode}}'));
2751
+ goBackStack.push(1);
2752
+ } else if (args.gotomesh != null) {
2753
+ if (meshes['mesh/' + domain + '/' + args.gotomesh] == null) return; // This device group is not loaded yet
2754
+ gotoMesh('mesh/' + domain + '/' + args.gotomesh);
2755
+ go(parseInt('{{viewmode}}'));
2756
+ goBackStack.push(2);
2757
+ } else if (args.gotouser != null) {
2758
+ if (users['user/' + domain + '/' + args.gotouser] == null) return; // This user is not loaded yet
2759
+ gotoUser('user/' + domain + '/' + args.gotouser);
2760
+ go(parseInt('{{viewmode}}'));
2761
+ goBackStack.push(4);
2762
+ } else if (args.gotougrp != null) {
2763
+ if (usergroups['ugrp/' + domain + '/' + args.gotougrp] == null) return; // This user group is not loaded yet
2764
+ gotoUserGroup('ugrp/' + domain + '/' + args.gotougrp);
2765
+ go(parseInt('{{viewmode}}'));
2766
+ goBackStack.push(50);
2767
+ } else if ('{{viewmode}}' != '') {
2768
+ go(parseInt('{{viewmode}}'));
2769
+ } else {
2770
+ setDialogMode(0);
2771
+ go(1);
2772
+ }
2773
+ delete args.gotonode;
2774
+ delete args.gotomesh;
2775
+ delete args.gotouser;
2776
+ delete args.gotougrp;
2777
+ }
2778
+
2779
//
2780
// MY DEVICES
2781
//
@@ -4738,6 +4765,7 @@
4765
4766
//disconnectAllKvmFunction();
4767
var node = getNodeFromId(nodeid);
4768
+ if (node == null) return;
4769
var mesh = meshes[node.meshid];
4770
var meshrights = GetNodeRights(node);
4771
if (!currentNode || currentNode._id != node._id || refresh == true) {