Module: check_mk
Branch: master
Commit: 819fd6ebea180fe26e28431fcd8870d42da3b111
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=819fd6ebea180f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Apr 18 08:43:17 2012 +0200
FIX: Automatically redirect from login page to target page when already
logged in
---
ChangeLog | 2 ++
web/htdocs/login.py | 15 ++++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e785791..27277ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -51,6 +51,8 @@
* Login page is not shown in framesets anymore (redirects framed page to
full screen login page)
* FIX: fix exception when disallowing changing display options
+ * FIX: Automatically redirect from login page to target page when already
+ logged in
BI
* FIX: Fixed filtering of Single-Host Aggregations
diff --git a/web/htdocs/login.py b/web/htdocs/login.py
index 30550c6..ba371f2 100644
--- a/web/htdocs/login.py
+++ b/web/htdocs/login.py
@@ -205,7 +205,7 @@ def page_login():
else:
return normal_login_page()
-def normal_login_page():
+def normal_login_page(called_directly = True):
# Working around the problem that the auth.php file needed for multisite based
# authorization of external addons might not exist when setting up a new
installation
# We assume: Each user must visit this login page before using the multisite based
@@ -220,15 +220,20 @@ def normal_login_page():
html.set_render_headfoot(False)
html.header(_("Check_MK Multisite Login"), javascripts=[],
stylesheets=["pages", "login"])
+ origtarget = html.var('_origtarget', '')
+ if not origtarget and not html.req.myfile == 'login':
+ origtarget = html.makeuri([])
+
+ # When someone calls the login page directly and is already authed redirect to main
page
+ if html.req.myfile == 'login' and check_auth() != '':
+ html.immediate_browser_redirect(0.5, origtarget and origtarget or
'index.py')
+ return
+
# Never allow the login page to be opened in a frameset. Redirect top page to login
page
html.javascript('''if(top != self) {
window.top.location.href = location;
}''')
- origtarget = html.var('_origtarget', '')
- if not origtarget and not html.req.myfile == 'login':
- origtarget = html.makeuri([])
-
html.write("<div id=login>")
html.write("<img id=login_window
src=\"images/login_window.png\">")
html.write("<div id=version>%s</div>" %
defaults.check_mk_version)