From 96bdc8dc09e1199478958077730662de8e95ccf3 Mon Sep 17 00:00:00 2001 From: "Petr Moravek (sean)" Date: Sun, 14 Apr 2019 22:22:32 +0200 Subject: [PATCH] Add pass through for token --- app/ui.js | 7 ++++++- vnc_lite.html | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/ui.js b/app/ui.js index 17ec48d4..fa8d78fd 100644 --- a/app/ui.js +++ b/app/ui.js @@ -1005,7 +1005,12 @@ const UI = { if (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, { shared: UI.getSetting('shared'), diff --git a/vnc_lite.html b/vnc_lite.html index 426d79b3..ae96b2d2 100644 --- a/vnc_lite.html +++ b/vnc_lite.html @@ -123,6 +123,17 @@ 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 // query string. If the variable isn't defined in the URL // it returns the default value instead. @@ -171,7 +182,12 @@ if(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 rfb = new RFB(document.getElementById('screen'), url,