Merge pull request #483 from halkyon/cms_ping_keepalive

Re-instate CMS ping to ensure sessions are kept alive
This commit is contained in:
Sean Harvey 2012-05-23 15:55:22 -07:00
commit 45465dca91
3 changed files with 25 additions and 27 deletions

View File

@ -74,6 +74,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
'getsubtree', 'getsubtree',
'printable', 'printable',
'show', 'show',
'ping',
'EditorToolbar', 'EditorToolbar',
'EditForm', 'EditForm',
'AddForm', 'AddForm',
@ -360,6 +361,13 @@ class LeftAndMain extends Controller implements PermissionProvider {
return $this->getResponseNegotiator()->respond($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 * If this is set to true, the "switchView" context in the

View File

@ -1,8 +1,8 @@
/** /**
* File: LeftAndMain.EditForm.js * File: LeftAndMain.Ping.js
*/ */
(function($) { (function($) {
$.entwine('ss', function($){ $.entwine('ss.ping', function($){
$('.cms-container').entwine(/** @lends ss.Form_EditForm */{ $('.cms-container').entwine(/** @lends ss.Form_EditForm */{
/** /**
@ -11,14 +11,14 @@
*/ */
PingIntervalSeconds: 5*60, PingIntervalSeconds: 5*60,
// onmatch: function() { onmatch: function() {
// this._super(); this._setupPinging();
// this._super();
// this._setupPinging(); },
// },
// onunmatch: function() { onunmatch: function() {
// this._super(); this._super();
// } },
/** /**
* Function: _setupPinging * Function: _setupPinging
@ -32,17 +32,17 @@
if(xmlhttp.status > 400 || xmlhttp.responseText == 0) { if(xmlhttp.status > 400 || xmlhttp.responseText == 0) {
// TODO will pile up additional alerts when left unattended // TODO will pile up additional alerts when left unattended
if(window.open('Security/login')) { if(window.open('Security/login')) {
alert("Please log in and then try again"); alert('Please log in and then try again');
} else { } else {
alert("Please enable pop-ups for this site"); alert('Please enable pop-ups for this site');
} }
} }
}; };
// setup pinging for login expiry // setup pinging for login expiry
setInterval(function() { setInterval(function() {
jQuery.ajax({ $.ajax({
url: "Security/ping", url: 'admin/security/ping',
global: false, global: false,
complete: onSessionLost complete: onSessionLost
}); });

View File

@ -14,7 +14,6 @@ class Security extends Controller {
'lostpassword', 'lostpassword',
'passwordsent', 'passwordsent',
'changepassword', 'changepassword',
'ping',
'LoginForm', 'LoginForm',
'ChangePasswordForm', 'ChangePasswordForm',
'LostPasswordForm', 'LostPasswordForm',
@ -590,15 +589,6 @@ class Security extends Controller {
return $customisedController->renderWith(array('Security_changepassword', 'Security', $this->stat('template_main'), 'BlankPage')); return $customisedController->renderWith(array('Security_changepassword', 'Security', $this->stat('template_main'), 'BlankPage'));
} }
/**
* 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 * Factory method for the lost password form
* *