From eb1c6a0be1751f8d2381c9346f61059c84cb5022 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 16 Mar 2020 15:23:59 -0700 Subject: [PATCH] Started work on agent install using invitation code. --- translate/translate.js | 1 + translate/translate.json | 31 ++++++ views/invite.handlebars | 202 +++++++++++++++++++++++++++++++++++++++ webserver.js | 15 +++ 4 files changed, 249 insertions(+) create mode 100644 views/invite.handlebars diff --git a/translate/translate.js b/translate/translate.js index e231a95b..110190a7 100644 --- a/translate/translate.js +++ b/translate/translate.js @@ -18,6 +18,7 @@ var minify = null; var meshCentralSourceFiles = [ "../views/agentinvite.handlebars", + "../views/invite.handlebars", "../views/default.handlebars", "../views/default-mobile.handlebars", "../views/download.handlebars", diff --git a/translate/translate.json b/translate/translate.json index 584a287e..00d72efb 100644 --- a/translate/translate.json +++ b/translate/translate.json @@ -7807,6 +7807,7 @@ "agentinvite.handlebars->container->topbar->uiMenuButton->uiMenu", "default.handlebars->container->topbar->1->1->uiMenuButton->uiMenu", "error404.handlebars->container->topbar->uiMenuButton->uiMenu", + "invite.handlebars->container->topbar->uiMenuButton->uiMenu", "login.handlebars->container->topbar->uiMenuButton->uiMenu", "terms.handlebars->container->topbar->uiMenuButton->uiMenu" ] @@ -9781,6 +9782,12 @@ "login.handlebars->5->9" ] }, + { + "en": "Invalid invitation code.", + "xloc": [ + "invite.handlebars->3->1" + ] + }, { "cs": "Neplatný token, zkuste to znovu.", "de": "Ungültiges Token, versuchen Sie es erneut.", @@ -9823,6 +9830,12 @@ "default.handlebars->27->263" ] }, + { + "en": "Invitation Code", + "xloc": [ + "invite.handlebars->container->column_l->5->1->0->3->1" + ] + }, { "cs": "Pozvat", "de": "Einladen", @@ -10524,6 +10537,7 @@ "agentinvite.handlebars->container->topbar->uiMenuButton->uiMenu", "default.handlebars->container->topbar->1->1->uiMenuButton->uiMenu", "error404.handlebars->container->topbar->uiMenuButton->uiMenu", + "invite.handlebars->container->topbar->uiMenuButton->uiMenu", "login.handlebars->container->topbar->uiMenuButton->uiMenu", "terms.handlebars->container->topbar->uiMenuButton->uiMenu" ] @@ -17805,6 +17819,12 @@ "login.handlebars->5->27" ] }, + { + "en": "Submit", + "xloc": [ + "invite.handlebars->container->column_l->5->1->0->3->3->3" + ] + }, { "cs": "Úspěch", "de": "Erfolg", @@ -18275,6 +18295,12 @@ "default.handlebars->27->1006" ] }, + { + "en": "This is a portal for computer remote management and support.", + "xloc": [ + "invite.handlebars->container->column_l->3" + ] + }, { "cs": "Toto není bezpečná zásada, protože aktivaci budou provádět agenti.", "de": "Dies ist keine sichere Richtlinie, da Agenten die Aktivierung durchführen.", @@ -18640,6 +18666,7 @@ "agentinvite.handlebars->container->topbar->uiMenuButton->uiMenu", "default.handlebars->container->topbar->1->1->uiMenuButton->uiMenu", "error404.handlebars->container->topbar->uiMenuButton->uiMenu", + "invite.handlebars->container->topbar->uiMenuButton->uiMenu", "login.handlebars->container->topbar->uiMenuButton->uiMenu", "terms.handlebars->container->topbar->uiMenuButton->uiMenu" ] @@ -18723,6 +18750,7 @@ "agentinvite.handlebars->container->topbar->uiMenuButton->uiMenu", "default.handlebars->container->topbar->1->1->uiMenuButton->uiMenu", "error404.handlebars->container->topbar->uiMenuButton->uiMenu", + "invite.handlebars->container->topbar->uiMenuButton->uiMenu", "login.handlebars->container->topbar->uiMenuButton->uiMenu", "terms.handlebars->container->topbar->uiMenuButton->uiMenu" ] @@ -19690,6 +19718,7 @@ "agentinvite.handlebars->container->topbar", "default.handlebars->container->topbar->1->1", "error404.handlebars->container->topbar", + "invite.handlebars->container->topbar", "login.handlebars->container->topbar", "terms.handlebars->container->topbar" ] @@ -20139,6 +20168,7 @@ "pt": "Bem vindo", "ru": "Добро пожаловать", "xloc": [ + "invite.handlebars->container->column_l->1", "login.handlebars->container->column_l->1" ] }, @@ -21922,6 +21952,7 @@ "agentinvite.handlebars->container->topbar->uiMenuButton", "default.handlebars->container->topbar->1->1->uiMenuButton", "error404.handlebars->container->topbar->uiMenuButton", + "invite.handlebars->container->topbar->uiMenuButton", "login.handlebars->container->topbar->uiMenuButton", "terms.handlebars->container->topbar->uiMenuButton" ] diff --git a/views/invite.handlebars b/views/invite.handlebars new file mode 100644 index 00000000..f743df1a --- /dev/null +++ b/views/invite.handlebars @@ -0,0 +1,202 @@ + + + + + + + + + + + Agent Installation + + + +
+ +
+
{{{titlehtml}}}
+
+ {{{title1}}} +
+
+ {{{title2}}} +
+

{{{logoutControl}}}

+
+
+
+
+
+
+ ♦ + +
+
+
+

Welcome

+

+ This is a portal for computer remote management and support. +

+ + + + + + +
+
Invitation Code
+
+
+
+
+ +
+
+ +
+ + + diff --git a/webserver.js b/webserver.js index e406d2d2..d1b436e2 100644 --- a/webserver.js +++ b/webserver.js @@ -1263,6 +1263,19 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { } } + // Called to process an agent invite GET/POST request + function handleInviteRequest(req, res) { + const domain = getDomain(req); + if (domain == null) { parent.debug('web', 'handleInviteRequest: failed checks.'); res.sendStatus(404); return; } + if ((domain.loginkey != null) && (domain.loginkey.indexOf(req.query.key) == -1)) { res.sendStatus(404); return; } // Check 3FA URL key + if ((req.body.inviteCode == null) || (req.body.inviteCode == '')) { render(req, res, getRenderPage('invite', req), getRenderArgs({ messageid: 0 }, domain)); return; } // No invitation code + + // Send invitation link, valid for 1 minute. + //res.redirect(domain.url + 'agentinvite?c=' + parent.encodeCookie({ a: 4, mid: 'mesh//xxxxx', f: 0, expire: 1 }, parent.invitationLinkEncryptionKey)); + + render(req, res, getRenderPage('invite', req), getRenderArgs({ messageid: 100 }, domain)); // Bad invitation code + } + // Called to process an agent invite request function handleAgentInviteRequest(req, res) { const domain = getDomain(req); @@ -3596,6 +3609,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { obj.app.post(url + 'resetpassword', handleResetPasswordRequest); obj.app.post(url + 'resetaccount', handleResetAccountRequest); obj.app.get(url + 'checkmail', handleCheckMailRequest); + obj.app.get(url + 'invite', handleInviteRequest); + obj.app.post(url + 'invite', handleInviteRequest); obj.app.get(url + 'agentinvite', handleAgentInviteRequest); obj.app.post(url + 'amtevents.ashx', obj.handleAmtEventRequest); obj.app.get(url + 'meshagents', obj.handleMeshAgentRequest);