From 18c2bf4d73efd13fa8f8ae0c16895cbeb0497ffd Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 24 Jan 2022 18:23:16 -0800 Subject: [PATCH] Added ?hide=x support to agent invite pages. --- views/agentinvite.handlebars | 43 +++++++++++++++++++++++++++------ views/default-mobile.handlebars | 4 +-- views/invite.handlebars | 20 ++++++++++++++- webserver.js | 2 +- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/views/agentinvite.handlebars b/views/agentinvite.handlebars index ad34bf62..d6a496c7 100644 --- a/views/agentinvite.handlebars +++ b/views/agentinvite.handlebars @@ -73,7 +73,7 @@ -
+

Remote Agent Installation

You have been invited to install an application that will allow a remote operator to securely access your computer including the desktop and files. Only follow the instructions below if this invitation was expected and you know who will be accessing your computer. Select your operating system and follow the instructions below for installation. @@ -183,14 +183,41 @@ var magenturl = '{{{magenturl}}}'; var groupName = decodeURIComponent('{{{meshname}}}'); var urlargs = parseUriArgs(); - if (groupName != '') { - QH('groupname', format("Remote Agent Installation for {0}", escapeHtml(groupName))); - document.title = format("{0} - Agent Installation", groupName); - } else { - document.title = "Agent Installation"; + + function startup() { + // Setup page visuals + var hide = 0; + var globalHide = parseInt('{{{hide}}}'); + if (globalHide || urlargs.hide) { + if (urlargs.hide) { hide = parseInt(urlargs.hide); } + if (globalHide) { hide = (hide | globalHide); } + } + urlargs.hide = hide; + QV('masthead', !(hide & 1)); + QV('topbar', !(hide & 2)); + QV('footer', !(hide & 4)); + if ((hide & 4) != 0) { QC('body').add('nofooter'); } else { QC('body').remove('nofooter'); } + if (hide != 0) { + // Fix the main grid to zero-height elements we want to hide. + if (uiMode == 2) { + QS('container')['grid-template-rows'] = ((hide & 1) ? '0' : '66') + 'px fit-content(48px) auto ' + ((hide & 4) ? '0' : '45') + 'px'; + QS('container')['-ms-grid-rows'] = ((hide & 1) ? '0' : '66') + 'px fit-content(48px) auto ' + ((hide & 4) ? '0' : '45') + 'px'; + } else { + QS('container')['grid-template-rows'] = ((hide & 1) ? '0' : '66') + 'px ' + ((hide & 2) ? '0' : '24') + 'px auto ' + ((hide & 4) ? '0' : '45') + 'px'; + QS('container')['-ms-grid-rows'] = ((hide & 1) ? '0' : '66') + 'px ' + ((hide & 2) ? '0' : '24') + 'px auto ' + ((hide & 4) ? '0' : '45') + 'px'; + } + } + + if (groupName != '') { + QH('groupname', format("Remote Agent Installation for {0}", escapeHtml(groupName))); + document.title = format("{0} - Agent Installation", groupName); + } else { + document.title = "Agent Installation"; + } + + userInterfaceSelectMenu(); + setup(); } - userInterfaceSelectMenu(); - setup(); // Create the QR code new QRCode(Q('android_qrimage'), { text: magenturl, width: 220, height: 220, colorDark: '#000000', colorLight: '#FFF', correctLevel: QRCode.CorrectLevel.M }); diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index e9852d66..0e4a4840 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -657,10 +657,10 @@

- {{{title1}}} + {{{title1}}}
- {{{title2}}} + {{{title2}}}
diff --git a/views/invite.handlebars b/views/invite.handlebars index 8370563d..984c7fc5 100644 --- a/views/invite.handlebars +++ b/views/invite.handlebars @@ -72,7 +72,7 @@
-
+

Welcome

This is a portal for computer remote management and support. @@ -117,6 +117,24 @@ function start() { if (urlargs.c != null) { Q('inviteCode').value = urlargs.c; } + // Setup page visuals + var hide = 0; + var globalHide = parseInt('{{{hide}}}'); + if (globalHide || urlargs.hide) { + if (urlargs.hide) { hide = parseInt(urlargs.hide); } + if (globalHide) { hide = (hide | globalHide); } + } + urlargs.hide = hide; + QV('masthead', !(hide & 1)); + QV('topbar', !(hide & 2)); + QV('footer', !(hide & 4)); + if ((hide & 4) != 0) { QC('body').add('nofooter'); } else { QC('body').remove('nofooter'); } + if (hide != 0) { + // Fix the main grid to zero-height elements we want to hide. + QS('container')['grid-template-rows'] = ((hide & 1) ? '0' : '66') + 'px fit-content(48px) auto ' + ((hide & 4) ? '0' : '45') + 'px'; + QS('container')['-ms-grid-rows'] = ((hide & 1) ? '0' : '66') + 'px fit-content(48px) auto ' + ((hide & 4) ? '0' : '45') + 'px'; + } + var messageid = parseInt('{{{messageid}}}'); var okmessages = ['']; var failmessages = ["Invalid invitation code."]; diff --git a/webserver.js b/webserver.js index 410c6280..fea20bac 100644 --- a/webserver.js +++ b/webserver.js @@ -1893,7 +1893,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF for (var i in obj.meshes) { if ((obj.meshes[i].domain == domain.id) && (obj.meshes[i].deleted == null) && (obj.meshes[i].invite != null) && (obj.meshes[i].invite.codes.indexOf(req.body.inviteCode) >= 0)) { // Send invitation link, valid for 1 minute. - res.redirect(domain.url + 'agentinvite?c=' + parent.encodeCookie({ a: 4, mid: i, f: obj.meshes[i].invite.flags, expire: 1 }, parent.invitationLinkEncryptionKey) + (req.query.key ? ('&key=' + req.query.key) : '')); + res.redirect(domain.url + 'agentinvite?c=' + parent.encodeCookie({ a: 4, mid: i, f: obj.meshes[i].invite.flags, expire: 1 }, parent.invitationLinkEncryptionKey) + (req.query.key ? ('&key=' + req.query.key) : '') + (req.query.hide ? ('&hide=' + req.query.hide) : '')); return; } }