Permalink
Browse files

ENHANCEMENT Re-instate pinging every 5 minutes in the CMS as a measure

to keep sessions alive. Moved Security/ping to admin/security/ping
  • Loading branch information...
1 parent 4267c03 commit ecf847b61cec008b4e3e7a0bf70a4a5f10836d36 @halkyon halkyon committed May 23, 2012
Showing with 25 additions and 27 deletions.
  1. +9 −1 admin/code/LeftAndMain.php
  2. +16 −16 admin/javascript/LeftAndMain.Ping.js
  3. +0 −10 security/Security.php
@@ -74,6 +74,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
'getsubtree',
'printable',
'show',
+ 'ping',
'EditorToolbar',
'EditForm',
'AddForm',
@@ -310,7 +311,7 @@ function init() {
else if($version == 8) Requirements::css(FRAMEWORK_ADMIN_DIR . '/css/ie8.css');
}
- // Custom requirements
+ // Custom requirements
foreach (self::$extra_requirements['javascript'] as $file) {
Requirements::javascript($file[0]);
}
@@ -360,6 +361,13 @@ function index($request) {
return $this->getResponseNegotiator()->respond($request);
}
+ /**
+ * admin/ping can be visited with ajax to keep a session alive.
+ * This is used in the CMS.
+ */
+ function ping() {
+ return 1;
+ }
/**
* If this is set to true, the "switchView" context in the
@@ -1,28 +1,28 @@
/**
- * File: LeftAndMain.EditForm.js
+ * File: LeftAndMain.Ping.js
*/
(function($) {
- $.entwine('ss', function($){
+ $.entwine('ss.ping', function($){
- $('.cms-container').entwine(/** @lends ss.Form_EditForm */{
+ $('.cms-container').entwine(/** @lends ss.Form_EditForm */{
/**
* Variable: PingIntervalSeconds
* (Number) Interval in which /Security/ping will be checked for a valid login session.
*/
PingIntervalSeconds: 5*60,
- // onmatch: function() {
- // this._super();
- //
- // this._setupPinging();
- // },
- // onunmatch: function() {
- // this._super();
- // }
+ onmatch: function() {
+ this._setupPinging();
+ this._super();
+ },
+
+ onunmatch: function() {
+ this._super();
+ },
/**
* Function: _setupPinging
- *
+ *
* This function is called by prototype when it receives notification that the user was logged out.
* It uses /Security/ping for this purpose, which should return '1' if a valid user session exists.
* It redirects back to the login form if the URL is either unreachable, or returns '0'.
@@ -32,17 +32,17 @@
if(xmlhttp.status > 400 || xmlhttp.responseText == 0) {
// TODO will pile up additional alerts when left unattended
if(window.open('Security/login')) {
- alert("Please log in and then try again");
+ alert('Please log in and then try again');
} else {
- alert("Please enable pop-ups for this site");
+ alert('Please enable pop-ups for this site');
}
}
};
// setup pinging for login expiry
setInterval(function() {
- jQuery.ajax({
- url: "Security/ping",
+ $.ajax({
+ url: 'admin/security/ping',
global: false,
complete: onSessionLost
});
View
@@ -14,7 +14,6 @@ class Security extends Controller {
'lostpassword',
'passwordsent',
'changepassword',
- 'ping',
'LoginForm',
'ChangePasswordForm',
'LostPasswordForm',
@@ -591,15 +590,6 @@ public function changepassword() {
}
/**
- * Security/ping can be visited with ajax to keep a session alive.
- * This is used in the CMS.
- */
- function ping() {
- return 1;
- }
-
-
- /**
* Factory method for the lost password form
*
* @return Form Returns the lost password form

0 comments on commit ecf847b

Please sign in to comment.