Do not try to redirect to login page when offline
This commit is contained in:
committed by
Frédéric Guillot
parent
1db83cddd0
commit
497f36983c
4
assets/js/app.min.js
vendored
4
assets/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -3,7 +3,7 @@ KB.interval(60, function () {
|
|||||||
var loginUrl = KB.find('body').data('loginUrl');
|
var loginUrl = KB.find('body').data('loginUrl');
|
||||||
|
|
||||||
if (KB.find('.form-login') === null) {
|
if (KB.find('.form-login') === null) {
|
||||||
KB.http.get(statusUrl).error(function () {
|
KB.http.get(statusUrl).authError(function () {
|
||||||
window.location = loginUrl;
|
window.location = loginUrl;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
KB.http.request = function (method, url, headers, body) {
|
KB.http.request = function (method, url, headers, body) {
|
||||||
var successCallback = function() {};
|
var successCallback = function() {};
|
||||||
|
var authErrorCallback = function() {};
|
||||||
|
var netErrorCallback = function() {};
|
||||||
var errorCallback = function() {};
|
var errorCallback = function() {};
|
||||||
|
|
||||||
function parseResponse(request) {
|
function parseResponse(request) {
|
||||||
@@ -42,10 +44,22 @@ KB.http.request = function (method, url, headers, body) {
|
|||||||
if (request.readyState === XMLHttpRequest.DONE) {
|
if (request.readyState === XMLHttpRequest.DONE) {
|
||||||
var response = parseResponse(request);
|
var response = parseResponse(request);
|
||||||
|
|
||||||
if (request.status === 200) {
|
// errorCallback still gets called for compatibility
|
||||||
successCallback(response);
|
switch (request.status) {
|
||||||
} else {
|
case 200:
|
||||||
errorCallback(response);
|
successCallback(response);
|
||||||
|
return;
|
||||||
|
case 401:
|
||||||
|
authErrorCallback(response);
|
||||||
|
errorCallback(response);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
netErrorCallback(response);
|
||||||
|
errorCallback(response);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errorCallback(response);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -59,6 +73,17 @@ KB.http.request = function (method, url, headers, body) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.authError = function (callback) {
|
||||||
|
authErrorCallback = callback;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.netError = function (callback) {
|
||||||
|
netErrorCallback = callback;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
// deprecated
|
||||||
this.error = function (callback) {
|
this.error = function (callback) {
|
||||||
errorCallback = callback;
|
errorCallback = callback;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
Reference in New Issue
Block a user