updated user consent for file access, so if request is cancelled, consent request is cancelled too, if supported.

This commit is contained in:
Bryan Roe 2020-04-28 12:15:36 -07:00
parent 0fbdb6cad8
commit 5ea705ea2a

View File

@ -1589,10 +1589,13 @@ function createMeshCore(agent) {
var pr = require('message-box').create('MeshCentral', this.httprequest.username + " requesting remote file access. Grant access?", 30); var pr = require('message-box').create('MeshCentral', this.httprequest.username + " requesting remote file access. Grant access?", 30);
pr.ws = this; pr.ws = this;
this.pause(); this.pause();
this._consentpromise = pr;
this.prependOnceListener('end', function () { if (this._consentpromise && this._consentpromise.close) { this._consentpromise.close(); } });
pr.then( pr.then(
function () { function ()
{
// Success // Success
this.ws._consentpromise = null;
MeshServerLog("Starting remote files after local user accepted (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest); MeshServerLog("Starting remote files after local user accepted (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null })); this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null }));
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 4)) { if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 4)) {
@ -1601,8 +1604,10 @@ function createMeshCore(agent) {
} }
this.ws.resume(); this.ws.resume();
}, },
function (e) { function (e)
{
// User Consent Denied/Failed // User Consent Denied/Failed
this.ws._consentpromise = null;
MeshServerLog("Failed to start remote files after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest); MeshServerLog("Failed to start remote files after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() })); this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
}); });