[icinga-checkins] icinga.org: icinga-web/master: * Check valid session and warn if expired ( fixes #606)

git at icinga.org git at icinga.org
Tue Jul 27 11:50:02 CEST 2010


Module: icinga-web
Branch: master
Commit: 1401a6174c348b8819de4b757909e68d602f425d
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=1401a6174c348b8819de4b757909e68d602f425d

Author: Marius Hein <marius.hein at netways.de>
Date:   Tue Jul 27 09:53:05 2010 +0200

* Check valid session and warn if expired (fixes #606)

---

 app/modules/AppKit/lib/js/AppKit.js                |    4 ++-
 app/modules/AppKit/lib/js/AppKitUtil.js            |   24 ++++++++++++++++++++
 .../AppKit/views/AjaxLoginSuccessView.class.php    |    6 ++++-
 app/modules/Cronks/lib/js/grid/MetaGridCreator.js  |    5 ++-
 4 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/app/modules/AppKit/lib/js/AppKit.js b/app/modules/AppKit/lib/js/AppKit.js
index 0fb2d55..e427314 100755
--- a/app/modules/AppKit/lib/js/AppKit.js
+++ b/app/modules/AppKit/lib/js/AppKit.js
@@ -43,7 +43,9 @@ var AppKit, _=function() { return Array.prototype.join.call(arguments, ' '); };
 			if (stateInitialData) {
 				stateProvider.initState(stateInitialData);
 			}
-			
+
+			AppKit.util.loginWatchdog();
+
 			me.ready = true;
 			me.fireEvent('appkit-ready');
 			
diff --git a/app/modules/AppKit/lib/js/AppKitUtil.js b/app/modules/AppKit/lib/js/AppKitUtil.js
index 94dad26..2f190f2 100755
--- a/app/modules/AppKit/lib/js/AppKitUtil.js
+++ b/app/modules/AppKit/lib/js/AppKitUtil.js
@@ -65,6 +65,30 @@ AppKit.util = (function() {
 				}
 			});
 		},
+
+		loginWatchdog : function(start) {
+			var t={}
+			Ext.Ajax.on('requestexception', function(conn, response, options) {
+				if (!options.url.match(/\/login/)) {
+					if (response.status == '401') {
+						if (Ext.isEmpty(this.wflag)) {
+							this.wflag=true;
+
+							Ext.Msg.show({
+								title: _('Session expired'),
+								msg: _('Your login session has gone away, press ok to login again!'),
+								icon: Ext.MessageBox.INFO,
+								buttons: Ext.MessageBox.OK,
+								fn: function() {
+									AppKit.changeLocation(AppKit.c.path);
+								}
+							});
+
+						}
+					}
+				}
+			}, t);
+		},
 		
 		/**
 		 * Handling the preferences editor
diff --git a/app/modules/AppKit/views/AjaxLoginSuccessView.class.php b/app/modules/AppKit/views/AjaxLoginSuccessView.class.php
index 043faca..0783c36 100755
--- a/app/modules/AppKit/views/AjaxLoginSuccessView.class.php
+++ b/app/modules/AppKit/views/AjaxLoginSuccessView.class.php
@@ -5,7 +5,10 @@ class AppKit_AjaxLoginSuccessView extends AppKitBaseView
 	public function executeHtml(AgaviRequestDataHolder $rd)
 	{
 		$this->setupHtml($rd);
-		// $this->setAttribute('title', 'Login');
+		
+		if ($this->getContext()->getUser()->isAuthenticated() !== true) {
+			$this->getResponse()->setHttpStatusCode('401');
+		}
 	}
 	
 	public function executeJson(AgaviRequestDataHolder $rd) {
@@ -19,6 +22,7 @@ class AppKit_AjaxLoginSuccessView extends AppKitBaseView
 		}
 		else {
 			$errors['username'] = 'Login failed!';
+			$this->getResponse()->setHttpStatusCode('401');
 		}
 		
 		return json_encode(array(
diff --git a/app/modules/Cronks/lib/js/grid/MetaGridCreator.js b/app/modules/Cronks/lib/js/grid/MetaGridCreator.js
index d7016d0..4a770a2 100755
--- a/app/modules/Cronks/lib/js/grid/MetaGridCreator.js
+++ b/app/modules/Cronks/lib/js/grid/MetaGridCreator.js
@@ -174,6 +174,7 @@ Cronk.grid.MetaGridCreator.prototype = {
 					for (var i in o.filter_params) { e=false; break; }
 					for (var i in o.filter_types) { e=false; break; }
 					for (var i in o.store_origin_params) { e=false; break; }
+
 					if (e == false) {
 						return o;
 					}
@@ -252,8 +253,8 @@ Cronk.grid.MetaGridCreator.prototype = {
 				pageSize:		this.pager_array.size,
 				store:			this.getMetaStore(),
 				displayInfo:	true,
-				displayMsg:		'Displaying topics {0} - {1} of {2}',
-				emptyMsg:		'No topics to display'
+				displayMsg:		_('Displaying topics {0} - {1} of {2}'),
+				emptyMsg:		_('No topics to display')
 			});
 		}
 		





More information about the icinga-checkins mailing list