summaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-29 17:18:23 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-29 17:18:23 -0500
commite72327d4b1fd92675372a118052f1c9847f882dc (patch)
tree8147a3ae0c6304769b8da747626467f032d1f171 /assets
parent7d36747de634f7101bdaeed38e634adbc5f11b02 (diff)
Improve session handler and add Ajax session check
Diffstat (limited to 'assets')
-rw-r--r--assets/js/app.js19
-rw-r--r--assets/js/base.js19
2 files changed, 38 insertions, 0 deletions
diff --git a/assets/js/app.js b/assets/js/app.js
index 65cc824a..ff584d87 100644
--- a/assets/js/app.js
+++ b/assets/js/app.js
@@ -128,6 +128,22 @@ var Kanboard = (function() {
$(".preview-area").hide();
},
+ // Check session and redirect to the login page if not logged
+ CheckSession: function() {
+
+ if (Kanboard.IsVisible() && ! $(".form-login").length) {
+ $.ajax({
+ cache: false,
+ url: $("body").data("status-url"),
+ statusCode: {
+ 401: function(data) {
+ window.location = $("body").data("login-url");
+ }
+ }
+ });
+ }
+ },
+
// Common init
Init: function() {
@@ -151,6 +167,9 @@ var Kanboard = (function() {
// Markdown Preview for textareas
$("#markdown-preview").click(Kanboard.MarkdownPreview);
$("#markdown-write").click(Kanboard.MarkdownWriter);
+
+ // Check the session every 10s
+ window.setInterval(Kanboard.CheckSession, 10000);
}
};
diff --git a/assets/js/base.js b/assets/js/base.js
index d6c332f4..30463970 100644
--- a/assets/js/base.js
+++ b/assets/js/base.js
@@ -113,6 +113,22 @@ var Kanboard = (function() {
$(".preview-area").hide();
},
+ // Check session and redirect to the login page if not logged
+ CheckSession: function() {
+
+ if (Kanboard.IsVisible() && ! $(".form-login").length) {
+ $.ajax({
+ cache: false,
+ url: $("body").data("status-url"),
+ statusCode: {
+ 401: function(data) {
+ window.location = $("body").data("login-url");
+ }
+ }
+ });
+ }
+ },
+
// Common init
Init: function() {
@@ -136,6 +152,9 @@ var Kanboard = (function() {
// Markdown Preview for textareas
$("#markdown-preview").click(Kanboard.MarkdownPreview);
$("#markdown-write").click(Kanboard.MarkdownWriter);
+
+ // Check the session every 10s
+ window.setInterval(Kanboard.CheckSession, 10000);
}
};