[Kimchi-devel] [PATCH 6/8] UI: Redirect user to console page after logging
Aline Manera
alinefm at linux.vnet.ibm.com
Mon May 5 18:08:18 UTC 2014
From: Aline Manera <alinefm at br.ibm.com>
vnc_auto.html and spice.html are now protected through Kimchi
authentication.
When a non-authenticated user tries to access those URLs he/she will be
redirected to login page. After it, he/she will get the console page
according to cookies console_type and console_uri (set by nginx)
Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
ui/js/src/kimchi.login_window.js | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/ui/js/src/kimchi.login_window.js b/ui/js/src/kimchi.login_window.js
index 44e5617..9c06a50 100644
--- a/ui/js/src/kimchi.login_window.js
+++ b/ui/js/src/kimchi.login_window.js
@@ -82,7 +82,24 @@ kimchi.login_main = function() {
kimchi.login(settings, function() {
var pAjax = kimchi.previousAjax;
- if (pAjax && true === pAjax['resend']) {
+ var consoleURL = kimchi.cookie.get("console_uri");
+ if (consoleURL) {
+ var path = /.*\/(.*?)\?.*/g.exec(consoleURL)[1];
+ var query = consoleURL.substr(consoleURL.indexOf("?") + 1);
+
+ var proxy_port = /.*port=(.*?)(&|$)/g.exec(consoleURL)[1];
+ var http_port = /.*kimchi=(.*?)(&|$)/g.exec(consoleURL);
+ var kimchi_port = http_port ? http_port[1] : location.port;
+
+ url = location.protocol + "//" + location.hostname;
+ url += ":" + proxy_port + "/console.html?url=" + path;
+ url += "&" + query;
+ url += "&kimchi=" + kimchi_port;
+
+ kimchi.cookie.remove("console_uri");
+ window.location.replace(url)
+ }
+ else if (pAjax && true === pAjax['resend']) {
pAjax['error'] = pAjax['originalError'];
$.ajax(pAjax);
kimchi.previousAjax = null;
--
1.7.10.4
More information about the Kimchi-devel
mailing list