Rewrite session check component in vanilla js
This commit is contained in:
parent
c0049ed7e6
commit
90c9e86461
File diff suppressed because one or more lines are too long
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -88,3 +88,7 @@ KB.render = function () {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
KB.interval = function (seconds, callback) {
|
||||
setInterval(callback, seconds * 1000);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue