Added user consent option on desktop connect button.

Ylian Saint-Hilaire committed Apr 14, 2020 at 19:12 UTC 1f0450529c9a89cae1a58f3831db8320983b7c35
3 files changed +31 -10
agents/meshcore.js
+5 -1
@@ -795,7 +795,7 @@ function createMeshCore(agent) {
795 if (process.platform != 'win32') break;
796 var p = require('user-sessions').enumerateUsers();
797 p.sessionid = data.sessionid;
798 - p.then(function (u) { mesh.SendCommand({ action: 'msg', type: 'userSessions', sessionid: data.sessionid, data: u }); });
798 + p.then(function (u) { mesh.SendCommand({ action: 'msg', type: 'userSessions', sessionid: data.sessionid, data: u, tag: data.tag }); });
799 break;
800 }
801 default:
@@ -1804,6 +1804,10 @@ function createMeshCore(agent) {
1804 //sendConsoleText('options: ' + JSON.stringify(obj));
1805 delete obj.type;
1806 ws.httprequest.xoptions = obj;
1807 +
1808 + // Set additional user consent options if present
1809 + if ((obj != null) && (typeof obj.consent == 'number')) { ws.httprequest.consent += obj.consent; }
1810 +
1811 break;
1812 }
1813 case 'close': {
views/default-mobile.handlebars
+1 -1
@@ -3482,7 +3482,7 @@
3482 // Check device group link permission
3483 var rights = 0, r = mesh.links[userid];
3484 if (r != null) {
3485 - if (rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device group link, stop here.
3485 + if (r.rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device group link, stop here.
3486 rights = r.rights;
3487 }
3488
views/default.handlebars
+25 -8
@@ -69,6 +69,9 @@
69 <div id="cxtermps" class="cmtext" onclick="cmtermaction(8,event)">User Shell</div>
70 <div id="cxtermps" class="cmtext" onclick="cmtermaction(100,event)">Login Shell</div>
71 </div>
72 + <div id="deskConnectContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
73 + <div id="cxdeskuc" class="cmtext" onclick="cmdeskaction(1,event)"><b>Ask Consent</b></div>
74 + </div>
75 <div id="altPortContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
76 <div id="cxaltport" class="cmtext" onclick="cmaltportaction(1,event)"><b>Alternate Port</b></div>
77 </div>
@@ -511,7 +514,7 @@
514 <div>
515 <div id="idx_deskFullBtn2" onclick=deskToggleFull(event)>&nbsp;&#x2716;</div>
516 <input type="button" id="autoconnectbutton1" value="AutoConnect" onclick=autoConnectDesktop(event) onkeypress="return false" onkeydown="return false" style="display:none" />
514 - <span id=connectbutton1span><input type=button id=connectbutton1 value="Connect" onclick=connectDesktop(event,3) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
517 + <span id=connectbutton1span><input type=button id=connectbutton1 cmenu="deskConnectButton" value="Connect" onclick=connectDesktop(event,3) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
518 <span id=connectbutton1hspan>&nbsp;<input type=button id=connectbutton1h value="HW Connect" title="Connect using Intel AMT hardware KVM" onclick=connectDesktop(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
519 <span id=disconnectbutton1span>&nbsp;<input type=button id=disconnectbutton1 value="Disconnect" onclick=connectDesktop(event,0) onkeypress="return false" onkeydown="return false" /></span>
520 &nbsp;<span id="deskstatus">Disconnected</span>
@@ -1902,12 +1905,12 @@
1905 // Got list of user sessions
1906 var userSessions = [];
1907 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]); } } }
1905 - if (userSessions.length == 0) { connectDesktop(null, 1); } // No active sessions, do a normal connection.
1906 - else if (userSessions.length == 1) { connectDesktop(null, 1, userSessions[0].SessionId); } // One active session, connect to it
1908 + if (userSessions.length == 0) { connectDesktop(null, 1, null, message.tag); } // No active sessions, do a normal connection.
1909 + else if (userSessions.length == 1) { connectDesktop(null, 1, userSessions[0].SessionId, message.tag); } // One active session, connect to it
1910 else {
1911 var x = '';
1912 for (var i in userSessions) {
1910 - x += '<div style="text-align:left;cursor:pointer;background-color:gray;margin:5px;padding:5px;border-radius:5px" onclick=connectDesktop(event,1,' + userSessions[i].SessionId + ')>' + userSessions[i].State + ', ' + userSessions[i].StationName;
1913 + x += '<div style="text-align:left;cursor:pointer;background-color:gray;margin:5px;padding:5px;border-radius:5px" onclick=connectDesktop(event,1,' + userSessions[i].SessionId + ',' + message.tag + ')>' + userSessions[i].State + ', ' + userSessions[i].StationName;
1914 if (userSessions[i].Username) { if (userSessions[i].Domain) { x += ' - ' + userSessions[i].Domain + '/' + userSessions[i].Username; } else { x += ' - ' + userSessions[i].Username; } }
1915 x += '</div>';
1916 }
@@ -4004,6 +4007,13 @@
4007 showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
4008 break;
4009 }
4010 + case 'deskConnectButton': {
4011 + // Desktop connect button context menu
4012 + if ((currentNode == null) || (currentNode.agent == null)) return true;
4013 + contextelement = elem;
4014 + showContextMenuDiv(document.getElementById('deskConnectContextMenu'), event.pageX, event.pageY);
4015 + break;
4016 + }
4017 case 'devsContentMenu': {
4018 // Device content menu
4019 contextelement = elem;
@@ -4094,6 +4104,10 @@
4104 }
4105 }
4106
4107 + function cmdeskaction(action) {
4108 + if (action == 1) { connectDesktop(null, 3, null, 0x0008); } // Do remote desktop connection using consent prompt
4109 + }
4110 +
4111 function cmaltportaction(action) {
4112 if (xxdialogMode) return;
4113 var x = "RDP remote connection port:" + '<br /><br /><input type=text placeholder="3389" inputmode="numeric" pattern="[0-9]*" onkeypress=\"return (event.keyCode == 8) || (event.charCode >= 48 && event.charCode <= 57)\" maxlength=5 id=d10rdpport type=text>';
@@ -4147,6 +4161,7 @@
4161 QV('meshContextMenu', false);
4162 QV('termShellContextMenu', false);
4163 QV('termShellContextMenuLinux', false);
4164 + QV('deskConnectContextMenu', false);
4165 QV('altPortContextMenu', false);
4166 QV('filesContextMenu', false);
4167 //QV('pluginTabContextMenu', false);
@@ -5748,7 +5763,7 @@
5763 var autoConnectDesktopTimer = null;
5764 function autoConnectDesktop(e) { if (autoConnectDesktopTimer == null) { autoConnectDesktopTimer = setInterval(function() { connectDesktop(null, 1) }, 1000); } else { clearInterval(autoConnectDesktopTimer); autoConnectDesktopTimer = null; } }
5765
5751 - function connectDesktop(e, contype, tsid) {
5766 + function connectDesktop(e, contype, tsid, consent) {
5767 if (xxdialogMode) return;
5768 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.
5769 QV('p11DeskSessionSelector', false);
@@ -5845,7 +5860,9 @@
5860 desktop.debugmode = debugmode;
5861 desktop.m.debugmode = debugmode;
5862 desktop.attemptWebRTC = attemptWebRTC;
5848 - if (tsid != null) { desktop.options = { tsid: tsid }; }
5863 + desktop.options = {};
5864 + if (tsid != null) { desktop.options.tsid = tsid; }
5865 + if (consent != null) { desktop.options.consent = consent; }
5866 desktop.onStateChanged = onDesktopStateChange;
5867 desktop.onConsoleMessageChange = function () {
5868 p11clearConsoleMsg();
@@ -5865,7 +5882,7 @@
5882 desktop.contype = 1;
5883 } else if (contype == 3) {
5884 // Ask for user sessions
5868 - meshserver.send({ action: 'msg', type: 'userSessions', nodeid: currentNode._id });
5885 + meshserver.send({ action: 'msg', type: 'userSessions', nodeid: currentNode._id, tag: consent });
5886 }
5887 } else {
5888 // Disconnect and clean up the remote desktop
@@ -11725,7 +11742,7 @@
11742 // Check device group link permission
11743 var rights = 0, r = mesh.links[userid];
11744 if (r != null) {
11728 - if (rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device group link, stop here.
11745 + if (r.rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device group link, stop here.
11746 rights = r.rights;
11747 }
11748