From b0e882bfaa2275cb07ea4058d735d52729783a8c Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 10 Feb 2020 16:36:03 -0800 Subject: [PATCH] Fixed user and user group permissions not updating in web page. --- meshuser.js | 1 + package.json | 2 +- translate/translate.json | 2 +- views/default-mobile.handlebars | 2 + views/default.handlebars | 84 ++++++++++++++++++++++----------- 5 files changed, 61 insertions(+), 30 deletions(-) diff --git a/meshuser.js b/meshuser.js index e9cb200b..6d44848e 100644 --- a/meshuser.js +++ b/meshuser.js @@ -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) { } } } diff --git a/package.json b/package.json index 58bcfc98..bb6299ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.4.8-x", + "version": "0.4.8-z", "keywords": [ "Remote Management", "Intel AMT", diff --git a/translate/translate.json b/translate/translate.json index 7ebbd1d6..7e1aa982 100644 --- a/translate/translate.json +++ b/translate/translate.json @@ -20955,4 +20955,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index 76cd2274..5f398b21 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -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; diff --git a/views/default.handlebars b/views/default.handlebars index 12aa381b..b99f8a4f 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -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) {