updated user consent for file access, so if request is cancelled, consent request is cancelled too, if supported.
Bryan Roe committed
Apr 28, 2020 at 12:15 UTC
ce58d71328724493faa6d3f0ff4aa3446ca00d97
1 file changed
+8
-3
agents/meshcore.js
+8
-3
@@ -1589,10 +1589,13 @@ function createMeshCore(agent) {
1589
var pr = require('message-box').create('MeshCentral', this.httprequest.username + " requesting remote file access. Grant access?", 30);
1590
pr.ws = this;
1591
this.pause();
1592
-
1592
+ this._consentpromise = pr;
1593
+ this.prependOnceListener('end', function () { if (this._consentpromise && this._consentpromise.close) { this._consentpromise.close(); } });
1594
pr.then(
1594
- function () {
1595
+ function ()
1596
+ {
1597
// Success
1598
+ this.ws._consentpromise = null;
1599
MeshServerLog("Starting remote files after local user accepted (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
1600
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null }));
1601
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 4)) {
@@ -1601,8 +1604,10 @@ function createMeshCore(agent) {
1604
}
1605
this.ws.resume();
1606
},
1604
- function (e) {
1607
+ function (e)
1608
+ {
1609
// User Consent Denied/Failed
1610
+ this.ws._consentpromise = null;
1611
MeshServerLog("Failed to start remote files after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
1612
this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
1613
});