Add pass through for token

This commit is contained in:
Petr Moravek (sean) 2019-04-14 22:22:32 +02:00
parent 9fe2fd04d4
commit 96bdc8dc09
2 changed files with 23 additions and 2 deletions

View File

@ -1005,7 +1005,12 @@ const UI = {
if (port) { if (port) {
url += ':' + port; url += ':' + port;
} }
url += '/' + path; token = getQueryVar("token","nope");
if (token=="nope") {
url += '/' + path;
} else {
url += '/' + path + '?token=' + token;
}
UI.rfb = new RFB(document.getElementById('noVNC_container'), url, UI.rfb = new RFB(document.getElementById('noVNC_container'), url,
{ shared: UI.getSetting('shared'), { shared: UI.getSetting('shared'),

View File

@ -123,6 +123,17 @@
document.getElementById('status').textContent = text; document.getElementById('status').textContent = text;
} }
function getQueryVar(name, defVal) {
"use strict";
const re = new RegExp('.*[?&]' + name + '=([^&#]*)'),
match = document.location.href.match(re);
if (typeof defVal === 'undefined') { defVal = null; }
if (match) {
return decodeURIComponent(match[1]);
}
return defVal;
}
// This function extracts the value of one variable from the // This function extracts the value of one variable from the
// query string. If the variable isn't defined in the URL // query string. If the variable isn't defined in the URL
// it returns the default value instead. // it returns the default value instead.
@ -171,7 +182,12 @@
if(port) { if(port) {
url += ':' + port; url += ':' + port;
} }
url += '/' + path; token = getQueryVar("token","nope");
if (token=="nope") {
url += '/' + path;
} else {
url += '/' + path + '?token=' + token;
}
// Creating a new RFB object will start a new connection // Creating a new RFB object will start a new connection
rfb = new RFB(document.getElementById('screen'), url, rfb = new RFB(document.getElementById('screen'), url,