Updated, so if terminal or kvm is cancelled berfore consent is granted, consent request is dismissed, if supported
Bryan Roe committed
Apr 28, 2020 at 12:09 UTC
604ce474681805cd923c1473c0755bbb448d536e
1 file changed
+14
-4
agents/meshcore.js
+14
-4
@@ -1330,11 +1330,14 @@ function createMeshCore(agent) {
1330
var pr = require('message-box').create('MeshCentral', that.httprequest.username + " requesting Terminal Access. Grant access?", 30);
1331
pr.ws = that;
1332
that.pause();
1333
+ that._consentpromise = pr;
1334
+ that.prependOnceListener('end', function () { if (this._consentpromise && this._consentpromise.close) { this._consentpromise.close(); } });
1335
1336
pr.then(
1337
function ()
1338
{
1339
// Success
1340
+ this.ws._consentpromise = null;
1341
MeshServerLog("Starting remote terminal after local user accepted (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
1342
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null }));
1343
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 2))
@@ -1347,6 +1350,7 @@ function createMeshCore(agent) {
1350
function (e)
1351
{
1352
// User Consent Denied/Failed
1353
+ this.ws._consentpromise = null;
1354
MeshServerLog("Failed to start remote terminal after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
1355
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
1356
this.ws.end();
@@ -1469,17 +1473,21 @@ function createMeshCore(agent) {
1473
}
1474
1475
// Perform notification if needed. Toast messages may not be supported on all platforms.
1472
- if (this.httprequest.consent && (this.httprequest.consent & 8)) {
1476
+ if (this.httprequest.consent && (this.httprequest.consent & 8))
1477
+ {
1478
// User Consent Prompt is required
1479
// Send a console message back using the console channel, "\n" is supported.
1480
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: "Waiting for user to grant access..." }));
1481
var pr = require('message-box').create('MeshCentral', this.httprequest.username + " requesting KVM Access. Grant access?", 30);
1482
pr.ws = this;
1483
this.pause();
1479
-
1484
+ this._consentpromise = pr;
1485
+ this.prependOnceListener('end', function () { if (this._consentpromise && this._consentpromise.close) { this._consentpromise.close(); }});
1486
pr.then(
1481
- function () {
1487
+ function ()
1488
+ {
1489
// Success
1490
+ this.ws._consentpromise = null;
1491
MeshServerLog("Starting remote desktop after local user accepted (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
1492
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null }));
1493
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 1)) {
@@ -1515,8 +1523,10 @@ function createMeshCore(agent) {
1523
this.ws.httprequest.desktop.kvm.pipe(this.ws, { dataTypeSkip: 1 });
1524
this.ws.resume();
1525
},
1518
- function (e) {
1526
+ function (e)
1527
+ {
1528
// User Consent Denied/Failed
1529
+ this.ws._consentpromise = null;
1530
MeshServerLog("Failed to start remote desktop after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
1531
this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
1532
});