Rewrite session check component in vanilla js

This commit is contained in:
Frederic Guillot 2016-12-10 13:05:35 -05:00
parent c0049ed7e6
commit 90c9e86461
4 changed files with 16 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
KB.interval(60, function () {
var statusUrl = KB.find('body').data('statusUrl');
var loginUrl = KB.find('body').data('loginUrl');
if (KB.find('.form-login') === null) {
KB.http.get(statusUrl).error(function () {
window.location = loginUrl;
});
}
});

View File

@ -88,3 +88,7 @@ KB.render = function () {
}
}
};
KB.interval = function (seconds, callback) {
setInterval(callback, seconds * 1000);
};

View File

@ -1,21 +0,0 @@
Kanboard.Session = function(app) {
this.app = app;
};
Kanboard.Session.prototype.execute = function() {
window.setInterval(this.checkSession, 60000);
};
Kanboard.Session.prototype.checkSession = function() {
if (! $(".form-login").length) {
$.ajax({
cache: false,
url: $("body").data("status-url"),
statusCode: {
401: function() {
window.location = $("body").data("login-url");
}
}
});
}
};