mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #483 from halkyon/cms_ping_keepalive
Re-instate CMS ping to ensure sessions are kept alive
This commit is contained in:
commit
45465dca91
@ -74,6 +74,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
|||||||
'getsubtree',
|
'getsubtree',
|
||||||
'printable',
|
'printable',
|
||||||
'show',
|
'show',
|
||||||
|
'ping',
|
||||||
'EditorToolbar',
|
'EditorToolbar',
|
||||||
'EditForm',
|
'EditForm',
|
||||||
'AddForm',
|
'AddForm',
|
||||||
@ -310,7 +311,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
|||||||
else if($version == 8) Requirements::css(FRAMEWORK_ADMIN_DIR . '/css/ie8.css');
|
else if($version == 8) Requirements::css(FRAMEWORK_ADMIN_DIR . '/css/ie8.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom requirements
|
// Custom requirements
|
||||||
foreach (self::$extra_requirements['javascript'] as $file) {
|
foreach (self::$extra_requirements['javascript'] as $file) {
|
||||||
Requirements::javascript($file[0]);
|
Requirements::javascript($file[0]);
|
||||||
}
|
}
|
||||||
@ -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
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
/**
|
/**
|
||||||
* 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 */{
|
||||||
/**
|
/**
|
||||||
* Variable: PingIntervalSeconds
|
* Variable: PingIntervalSeconds
|
||||||
* (Number) Interval in which /Security/ping will be checked for a valid login session.
|
* (Number) Interval in which /Security/ping will be checked for a valid login session.
|
||||||
*/
|
*/
|
||||||
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
|
||||||
*
|
*
|
||||||
* This function is called by prototype when it receives notification that the user was logged out.
|
* 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 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'.
|
* 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) {
|
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
|
||||||
});
|
});
|
||||||
|
@ -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
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user