Module: check_mk
Branch: master
Commit: df41d699e27642e0bd61f6fe7b161c88b5f62426
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=df41d699e27642…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Dec 6 10:31:00 2011 +0100
login dialog: Preventing multiple login dialogs in open framesets by reloading the page
---
web/htdocs/index.py | 11 +++++++++++
web/htdocs/js/check_mk.js | 10 ++++++++++
web/htdocs/lib.py | 3 +++
3 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/web/htdocs/index.py b/web/htdocs/index.py
index 4e2e2f3..9e67d4f 100644
--- a/web/htdocs/index.py
+++ b/web/htdocs/index.py
@@ -252,6 +252,10 @@ def handler(req, profiling = True):
# When not authed tell the browser to ask for the password
req.user = login.check_auth()
if req.user == '':
+ if fail_silently:
+ # While api call don't show the login dialog
+ raise MKUnauthenticatedException(_('You are not
authenticated.'))
+
# After auth check the regular page can be shown
result = login.page_login()
if type(result) == tuple:
@@ -311,6 +315,13 @@ def handler(req, profiling = True):
html.show_error(str(e))
html.footer()
+ except MKUnauthenticatedException, e:
+ if not fail_silently:
+ html.header(_("Not authenticated"))
+ html.show_error(str(e))
+ html.footer()
+ response_code = apache.HTTP_UNAUTHORIZED
+
except MKConfigError, e:
if not fail_silently:
html.header(_("Configuration Error"))
diff --git a/web/htdocs/js/check_mk.js b/web/htdocs/js/check_mk.js
index 4688b88..605d7dd 100644
--- a/web/htdocs/js/check_mk.js
+++ b/web/htdocs/js/check_mk.js
@@ -110,6 +110,16 @@ function get_url(url, handler, data, errorHandler) {
if (AJAX.status == 200) {
handler(data, AJAX.responseText);
}
+ else if (AJAX.status == 401) {
+ // This is reached when someone is not authenticated anymore
+ // but has some webservices running which are still fetching
+ // infos via AJAX. Reload the whole frameset or only the
+ // single page in that case.
+ if(top)
+ top.location.reload();
+ else
+ document.location.reload();
+ }
else {
if (typeof errorHandler !== 'undefined')
errorHandler(data, AJAX.status);
diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py
index 92bd4e9..837426b 100644
--- a/web/htdocs/lib.py
+++ b/web/htdocs/lib.py
@@ -42,6 +42,9 @@ class MKAuthException(Exception):
def __str__(self):
return str(self.reason)
+class MKUnauthenticatedException(MKGeneralException):
+ pass
+
class MKConfigError(Exception):
def __init__(self, msg):
Exception.__init__(self, msg)