[Pkg-owncloud-commits] [owncloud] 56/145: Added session_keepalive setting
David Prévot
taffit at moszumanska.debian.org
Wed Feb 26 16:27:42 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 7b948b058037ff7b80e0e272ab94036d1c55d76b
Author: Vincent Petry <pvince81 at owncloud.com>
Date: Tue Feb 4 13:56:10 2014 +0100
Added session_keepalive setting
When session_keepalive is true (default) the heartbeat will be send as
often as the half of the session timeout value.
Backport of 912da8d to stable6
---
config/config.sample.php | 7 +++++++
core/js/config.php | 6 ++++++
core/js/js.js | 53 ++++++++++++++++++++++++++++++++++--------------
3 files changed, 51 insertions(+), 15 deletions(-)
diff --git a/config/config.sample.php b/config/config.sample.php
index 1070ef7..eaf9eba 100755
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -178,6 +178,13 @@ $CONFIG = array(
/* Life time of a session after inactivity */
"session_lifetime" => 60 * 60 * 24,
+/*
+ * Enable/disable session keep alive when a user is logged in in the Web UI.
+ * This is achieved by sending a "heartbeat" to the server to prevent
+ * the session timing out.
+ */
+"session_keepalive" => true,
+
/* Custom CSP policy, changing this will overwrite the standard policy */
"custom_csp_policy" => "default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-src *; img-src *; font-src 'self' data:; media-src *",
diff --git a/core/js/config.php b/core/js/config.php
index dd46f78..517ea16 100644
--- a/core/js/config.php
+++ b/core/js/config.php
@@ -55,6 +55,12 @@ $array = array(
)
),
"firstDay" => json_encode($l->l('firstday', 'firstday')) ,
+ "oc_config" => json_encode(
+ array(
+ 'session_lifetime' => \OCP\Config::getSystemValue('session_lifetime', 60 * 60 * 24),
+ 'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true)
+ )
+ )
);
// Echo it
diff --git a/core/js/js.js b/core/js/js.js
index 3650d05..c79d5e8 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -11,6 +11,8 @@ var oc_webroot;
var oc_current_user = document.getElementsByTagName('head')[0].getAttribute('data-user');
var oc_requesttoken = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken');
+window.oc_config = window.oc_config || {};
+
if (typeof oc_webroot === "undefined") {
oc_webroot = location.pathname;
var pos = oc_webroot.indexOf('/index.php/');
@@ -705,8 +707,39 @@ function fillWindow(selector) {
console.warn("This function is deprecated! Use CSS instead");
}
-$(document).ready(function(){
- sessionHeartBeat();
+/**
+ * Initializes core
+ */
+function initCore() {
+
+ /**
+ * Calls the server periodically to ensure that session doesnt
+ * time out
+ */
+ function initSessionHeartBeat(){
+ // interval in seconds
+ var interval = 900;
+ if (oc_config.session_lifetime) {
+ interval = Math.floor(oc_config.session_lifetime / 2);
+ }
+ // minimum one minute
+ if (interval < 60) {
+ interval = 60;
+ }
+ OC.Router.registerLoadedCallback(function(){
+ var url = OC.Router.generate('heartbeat');
+ setInterval(function(){
+ $.post(url);
+ }, interval * 1000);
+ });
+ }
+
+ // session heartbeat (defalts to enabled)
+ if (typeof(oc_config.session_keepalive) === 'undefined' ||
+ !!oc_config.session_keepalive) {
+
+ initSessionHeartBeat();
+ }
if(!SVGSupport()){ //replace all svg images with png images for browser that dont support svg
replaceSVG();
@@ -819,7 +852,9 @@ $(document).ready(function(){
$('input[type=text]').focus(function(){
this.select();
});
-});
+}
+
+$(document).ready(initCore);
/**
* Filter Jquery selector by attribute value
@@ -946,15 +981,3 @@ jQuery.fn.exists = function(){
return this.length > 0;
};
-/**
- * Calls the server periodically every 15 mins to ensure that session doesnt
- * time out
- */
-function sessionHeartBeat(){
- OC.Router.registerLoadedCallback(function(){
- var url = OC.Router.generate('heartbeat');
- setInterval(function(){
- $.post(url);
- }, 900000);
- });
-}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list