Started work on agent install using invitation code.

This commit is contained in:
Ylian Saint-Hilaire 2020-03-16 15:23:59 -07:00
parent bc6e403c4e
commit eb1c6a0be1
4 changed files with 249 additions and 0 deletions

View File

@ -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",

View File

@ -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"
]

202
views/invite.handlebars Normal file
View File

@ -0,0 +1,202 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta name="viewport" content="user-scalable=1.0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no" />
<link type="text/css" href="styles/style.css" media="screen" rel="stylesheet" title="CSS" />
<script type="text/javascript" src="scripts/common-0.0.1.js"></script>
<title>Agent Installation</title>
<style>
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
}
.tab button:hover {
background-color: #ddd;
}
.tab button.active {
background-color: #8f8;
}
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
</style>
</head>
<body id="body" onload="if (typeof(startup) !== 'undefined') startup();" style="display:none;overflow:hidden">
<div id="container">
<!-- Begin Masthead -->
<div id="masthead" class=noselect style="background:url(logo.png) 0px 0px;background-color:#036;background-repeat:no-repeat;height:66px;width:100%;overflow:hidden;">
<div style="float:left">{{{titlehtml}}}</div>
<div style="float:left; height: 66px; color:#c8c8c8; padding-left:14px; padding-top:7px">
<strong><font style="font-size:46px; font-family: Arial, Helvetica, sans-serif;">{{{title1}}}</font></strong>
</div>
<div style="float:left; height: 66px; color:#c8c8c8; padding-left:5px; padding-top:14px">
<strong><font style="font-size:14px; font-family: Arial, Helvetica, sans-serif;">{{{title2}}}</font></strong>
</div>
<p id="logoutControl" style="color:white;font-size:11px;margin: 10px 10px 0;">{{{logoutControl}}}</p>
</div>
<div id="page_leftbar">
<div style="height:16px"></div>
</div>
<div id=topbar class="noselect style3" style="height:24px;position:relative">
<div id=uiMenuButton title="User interface selection" onclick="showUserInterfaceSelectMenu()">
&diams;
<div id=uiMenu style="display:none">
<div id=uiViewButton1 class=uiSelector onclick=userInterfaceSelectMenu(1) title="Left bar interface"><div class="uiSelector1"></div></div>
<div id=uiViewButton2 class=uiSelector onclick=userInterfaceSelectMenu(2) title="Top bar interface"><div class="uiSelector2"></div></div>
<div id=uiViewButton3 class=uiSelector onclick=userInterfaceSelectMenu(3) title="Fixed width interface"><div class="uiSelector3"></div></div>
<div id=uiViewButton4 class=uiSelector onclick=toggleNightMode() title="Toggle night mode"><div class="uiSelector4"></div></div>
</div>
</div>
</div>
<div id="column_l" style="max-height:calc(100vh - 135px);overflow-y:auto">
<h1>Welcome</h1>
<p>
This is a portal for computer remote management and support.
</p>
<table style="text-align:center;margin-top:60px;width:100%">
<tr>
<td style="width:33%"></td>
<td style="font-size:20px;background-color:#DDD;padding:12px;border-radius:16px">
<div style="margin-bottom:10px">Invitation&nbsp;Code</div>
<form method=post>
<div><input id="inviteCode" name="inviteCode" style="font-size:26px;text-align:center;border-radius:6px" maxlength="20" /></div>
<div><input type="submit" style="margin-top:10px" value="Submit" /></div>
</form>
<div id="message" style="margin-top:8px;font-size:16px;display:none"></div>
</td>
<td style="width:33%"></td>
</tr>
</table>
</div>
<div id="footer">
<table cellpadding="0" cellspacing="10" style="width: 100%">
<tr>
<td style="text-align:left"></td>
<td style="text-align:right"></td>
</tr>
</table>
</div>
</div>
<script>
'use strict';
var urlargs = parseUriArgs();
var uiMode = parseInt(getstore('uiMode', 1));
var webPageStackMenu = false;
var webPageFullScreen = true;
var nightMode = (getstore('_nightMode', '0') == '1');
userInterfaceSelectMenu();
Q('inviteCode').focus();
start();
document.onclick = function (e) { Q('inviteCode').focus(); }
function start() {
if (urlargs.c != null) { Q('inviteCode').value = urlargs.c; }
var messageid = parseInt('{{{messageid}}}');
var okmessages = [''];
var failmessages = ["Invalid invitation code."];
if (messageid > 0) {
var msg = '';
if ((messageid < 100) && (messageid < okmessages.length)) { msg = okmessages[messageid]; }
else if ((messageid >= 100) && ((messageid - 100) < failmessages.length)) { msg = failmessages[messageid - 100]; }
if (msg != '') {
if (messageid >= 100) { msg = ('<span class="msg error"><b style=color:#8C001A>' + msg + '<b></span>'); } else { msg = ('<span class="msg success"><b>' + msg + '</b></span>'); }
QH('message', msg);
QV('message', true);
}
}
}
// Toggle user interface menu
function showUserInterfaceSelectMenu() {
Q('uiViewButton1').classList.remove('uiSelectorSel');
Q('uiViewButton2').classList.remove('uiSelectorSel');
Q('uiViewButton3').classList.remove('uiSelectorSel');
Q('uiViewButton4').classList.remove('uiSelectorSel');
try { Q('uiViewButton' + uiMode).classList.add('uiSelectorSel'); } catch (ex) { }
QV('uiMenu', (QS('uiMenu').display == 'none'));
if (nightMode) { Q('uiViewButton4').classList.add('uiSelectorSel'); }
}
function userInterfaceSelectMenu(s) {
if (s) { uiMode = s; putstore('uiMode', uiMode); }
webPageFullScreen = (uiMode < 3);
webPageStackMenu = true;//(uiMode > 1);
toggleFullScreen(0);
toggleStackMenu(0);
QC('column_l').add('room4submenu');
}
function toggleNightMode() {
nightMode = !nightMode;
if (nightMode) { QC('body').add('night'); } else { QC('body').remove('night'); }
putstore('_nightMode', nightMode ? '1' : '0');
}
// Toggle the web page to full screen
function toggleFullScreen(toggle) {
if (toggle === 1) { webPageFullScreen = !webPageFullScreen; putstore('webPageFullScreen', webPageFullScreen); }
var hide = 0;
//if (args.hide) { hide = parseInt(args.hide); }
if (webPageFullScreen == false) {
QC('body').remove('menu_stack');
QC('body').remove('fullscreen');
QC('body').remove('arg_hide');
//if (xxcurrentView >= 10) QC('column_l').add('room4submenu');
//QV('UserDummyMenuSpan', false);
//QV('page_leftbar', false);
} else {
QC('body').add('fullscreen');
if (hide & 16) QC('body').add('arg_hide'); // This is replacement for QV('page_leftbar', !(hide & 16));
//QV('UserDummyMenuSpan', (xxcurrentView < 10) && webPageFullScreen);
//QV('page_leftbar', true);
}
QV('body', true);
}
// If FullScreen, toggle menu to be horisontal or vertical
function toggleStackMenu(toggle) {
if (webPageFullScreen == true) {
if (toggle === 1) {
webPageStackMenu = !webPageStackMenu;
putstore('webPageStackMenu', webPageStackMenu);
}
if (webPageStackMenu == false) {
QC('body').remove('menu_stack');
} else {
QC('body').add('menu_stack');
//if (xxcurrentView >= 10) QC('column_l').remove('room4submenu');
}
}
}
function putstore(name, val) { try { if (typeof (localStorage) === 'undefined') return; localStorage.setItem(name, val); } catch (e) { } }
function getstore(name, val) { try { if (typeof (localStorage) === 'undefined') return val; var v = localStorage.getItem(name); if ((v == null) || (v == null)) return val; return v; } catch (e) { return val; } }
function format(format) { var args = Array.prototype.slice.call(arguments, 1); return format.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match; }); };
function parseUriArgs() { var href = window.document.location.href; if (href.endsWith('#')) { href = href.substring(0, href.length - 1); } var name, r = {}, parsedUri = href.split(/[\?&|\=]/); parsedUri.splice(0, 1); for (x in parsedUri) { switch (x % 2) { case 0: { name = decodeURIComponent(parsedUri[x]); break; } case 1: { r[name] = decodeURIComponent(parsedUri[x]); var x = parseInt(r[name]); if (x == r[name]) { r[name] = x; } break; } default: { break; } } } return r; }
</script>
</body>
</html>

View File

@ -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);