mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-02 11:26:04 +01:00
Merge pull request #170 from getgrav/feature/keepalive-in-admin
Keepalive in admin. Fires a 'keepAlive' task 5s before the end of the admin session
This commit is contained in:
@@ -193,6 +193,16 @@ class AdminController
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle logout.
|
||||
*
|
||||
* @return bool True if the action was performed.
|
||||
*/
|
||||
protected function taskKeepAlive()
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the email password recovery procedure.
|
||||
*
|
||||
|
||||
@@ -20,6 +20,10 @@ var bytesToSize = function(bytes) {
|
||||
|
||||
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
||||
|
||||
var keepAlive = function keepAlive() {
|
||||
$.post(GravAdmin.config.base_url_relative + '/task' + GravAdmin.config.param_sep + 'keepAlive');
|
||||
};
|
||||
|
||||
$(function () {
|
||||
jQuery.substitute = function(str, sub) {
|
||||
return str.replace(/\{(.+?)\}/g, function($0, $1) {
|
||||
@@ -513,4 +517,10 @@ $(function () {
|
||||
remodal.find('strong').text(name);
|
||||
remodal.find('.button.continue').attr('href', $(e.target).attr('href'));
|
||||
});
|
||||
|
||||
// Keep-alive
|
||||
setInterval(function() {
|
||||
keepAlive();
|
||||
}, GravAdmin.config.admin_timeout*1000 - 5*1000); //Call keepAlive() 5s before the admin session timeout
|
||||
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
window.GravAdmin.config = {
|
||||
base_url_relative: '{{ base_url_relative }}',
|
||||
param_sep: '{{ config.system.param_sep }}',
|
||||
enable_auto_updates_check: '{{ config.plugins.admin.enable_auto_updates_check }}'
|
||||
enable_auto_updates_check: '{{ config.plugins.admin.enable_auto_updates_check }}',
|
||||
admin_timeout: '{{ config.plugins.admin.session.timeout ?: 1800 }}'
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user