From 1f0450529c9a89cae1a58f3831db8320983b7c35 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 14 Apr 2020 19:12:14 -0700 Subject: [PATCH] Added user consent option on desktop connect button. --- agents/meshcore.js | 6 +++++- views/default-mobile.handlebars | 2 +- views/default.handlebars | 33 +++++++++++++++++++++++++-------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/agents/meshcore.js b/agents/meshcore.js index b802d424..82ee7667 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -795,7 +795,7 @@ function createMeshCore(agent) { if (process.platform != 'win32') break; var p = require('user-sessions').enumerateUsers(); p.sessionid = data.sessionid; - p.then(function (u) { mesh.SendCommand({ action: 'msg', type: 'userSessions', sessionid: data.sessionid, data: u }); }); + p.then(function (u) { mesh.SendCommand({ action: 'msg', type: 'userSessions', sessionid: data.sessionid, data: u, tag: data.tag }); }); break; } default: @@ -1804,6 +1804,10 @@ function createMeshCore(agent) { //sendConsoleText('options: ' + JSON.stringify(obj)); delete obj.type; ws.httprequest.xoptions = obj; + + // Set additional user consent options if present + if ((obj != null) && (typeof obj.consent == 'number')) { ws.httprequest.consent += obj.consent; } + break; } case 'close': { diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index 0f7b66ce..f332d594 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -3482,7 +3482,7 @@ // Check device group link permission var rights = 0, r = mesh.links[userid]; if (r != null) { - if (rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device group link, stop here. + if (r.rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device group link, stop here. rights = r.rights; } diff --git a/views/default.handlebars b/views/default.handlebars index cf5d8077..b2b5112e 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -69,6 +69,9 @@
User Shell
Login Shell
+ @@ -511,7 +514,7 @@
 ✖
- +      Disconnected @@ -1902,12 +1905,12 @@ // Got list of user sessions var userSessions = []; if (message.data != null) { for (var i in message.data) { if ((message.data[i].State == 'Active') || (message.data[i].StationName == 'Console') || (debugmode == 3)) { userSessions.push(message.data[i]); } } } - if (userSessions.length == 0) { connectDesktop(null, 1); } // No active sessions, do a normal connection. - else if (userSessions.length == 1) { connectDesktop(null, 1, userSessions[0].SessionId); } // One active session, connect to it + if (userSessions.length == 0) { connectDesktop(null, 1, null, message.tag); } // No active sessions, do a normal connection. + else if (userSessions.length == 1) { connectDesktop(null, 1, userSessions[0].SessionId, message.tag); } // One active session, connect to it else { var x = ''; for (var i in userSessions) { - x += '
' + userSessions[i].State + ', ' + userSessions[i].StationName; + x += '
' + userSessions[i].State + ', ' + userSessions[i].StationName; if (userSessions[i].Username) { if (userSessions[i].Domain) { x += ' - ' + userSessions[i].Domain + '/' + userSessions[i].Username; } else { x += ' - ' + userSessions[i].Username; } } x += '
'; } @@ -4004,6 +4007,13 @@ showContextMenuDiv(contextmenudiv, event.pageX, event.pageY); break; } + case 'deskConnectButton': { + // Desktop connect button context menu + if ((currentNode == null) || (currentNode.agent == null)) return true; + contextelement = elem; + showContextMenuDiv(document.getElementById('deskConnectContextMenu'), event.pageX, event.pageY); + break; + } case 'devsContentMenu': { // Device content menu contextelement = elem; @@ -4094,6 +4104,10 @@ } } + function cmdeskaction(action) { + if (action == 1) { connectDesktop(null, 3, null, 0x0008); } // Do remote desktop connection using consent prompt + } + function cmaltportaction(action) { if (xxdialogMode) return; var x = "RDP remote connection port:" + '

= 48 && event.charCode <= 57)\" maxlength=5 id=d10rdpport type=text>'; @@ -4147,6 +4161,7 @@ QV('meshContextMenu', false); QV('termShellContextMenu', false); QV('termShellContextMenuLinux', false); + QV('deskConnectContextMenu', false); QV('altPortContextMenu', false); QV('filesContextMenu', false); //QV('pluginTabContextMenu', false); @@ -5748,7 +5763,7 @@ var autoConnectDesktopTimer = null; function autoConnectDesktop(e) { if (autoConnectDesktopTimer == null) { autoConnectDesktopTimer = setInterval(function() { connectDesktop(null, 1) }, 1000); } else { clearInterval(autoConnectDesktopTimer); autoConnectDesktopTimer = null; } } - function connectDesktop(e, contype, tsid) { + function connectDesktop(e, contype, tsid, consent) { if (xxdialogMode) return; if ((e != null) && (e.shiftKey != false) && (contype == 3)) { contype = 1; } // If the shift key is not pressed, don't try to ask for session list. QV('p11DeskSessionSelector', false); @@ -5845,7 +5860,9 @@ desktop.debugmode = debugmode; desktop.m.debugmode = debugmode; desktop.attemptWebRTC = attemptWebRTC; - if (tsid != null) { desktop.options = { tsid: tsid }; } + desktop.options = {}; + if (tsid != null) { desktop.options.tsid = tsid; } + if (consent != null) { desktop.options.consent = consent; } desktop.onStateChanged = onDesktopStateChange; desktop.onConsoleMessageChange = function () { p11clearConsoleMsg(); @@ -5865,7 +5882,7 @@ desktop.contype = 1; } else if (contype == 3) { // Ask for user sessions - meshserver.send({ action: 'msg', type: 'userSessions', nodeid: currentNode._id }); + meshserver.send({ action: 'msg', type: 'userSessions', nodeid: currentNode._id, tag: consent }); } } else { // Disconnect and clean up the remote desktop @@ -11725,7 +11742,7 @@ // Check device group link permission var rights = 0, r = mesh.links[userid]; if (r != null) { - if (rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device group link, stop here. + if (r.rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device group link, stop here. rights = r.rights; }