mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-06-19 04:15:17 +00:00
Improve bad token handling
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
ComunicWeb.common.api = {
|
||||
const APIClient = {
|
||||
|
||||
/**
|
||||
* Make an asynchronous request over the API
|
||||
@ -151,14 +151,7 @@ ComunicWeb.common.api = {
|
||||
if(apiXHR.readyState == 4){
|
||||
|
||||
//Check if response code is 0
|
||||
if(apiXHR.status == 0){
|
||||
//An error occured
|
||||
ComunicWeb.common.network.setStatus(false);
|
||||
}
|
||||
else{
|
||||
//It is a success
|
||||
ComunicWeb.common.network.setStatus(true);
|
||||
}
|
||||
ComunicWeb.common.network.setStatus(apiXHR.status != 0);
|
||||
|
||||
//Check if response is empty
|
||||
if(apiXHR.responseText.length == ""){
|
||||
@ -199,6 +192,12 @@ ComunicWeb.common.api = {
|
||||
if(result.error){
|
||||
//Log error
|
||||
ComunicWeb.debug.logMessage("Got an error in a XHR request! \n Request URL: "+requestURL+" \n Response : "+apiXHR.responseText);
|
||||
|
||||
if (result.error.code == 412) {
|
||||
UserLogin.__userLogin = false;
|
||||
ComunicWeb.user.loginTokens.deleteLoginTokens();
|
||||
System.restart();
|
||||
}
|
||||
}
|
||||
|
||||
//We can do the next step
|
||||
@ -206,4 +205,6 @@ ComunicWeb.common.api = {
|
||||
nextAction(result);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
ComunicWeb.common.api = APIClient;
|
@ -14,7 +14,7 @@
|
||||
* @return {Promise}
|
||||
*/
|
||||
function api(uri, args, withLogin){
|
||||
return ComunicWeb.common.api.exec(uri, args, withLogin);
|
||||
return APIClient.exec(uri, args, withLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
ComunicWeb.common.system = {
|
||||
const System = {
|
||||
/**
|
||||
* Initializate the application
|
||||
*
|
||||
@ -94,7 +94,7 @@ ComunicWeb.common.system = {
|
||||
ComunicWeb.common.page.showWaitSplashScreen("Restarting...");
|
||||
|
||||
//Reload the page
|
||||
location.href = document.location;
|
||||
location.href = document.location.href.split("#")[0];
|
||||
},
|
||||
|
||||
/**
|
||||
@ -120,4 +120,6 @@ ComunicWeb.common.system = {
|
||||
//Success
|
||||
return true;
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
ComunicWeb.common.system = System;
|
Reference in New Issue
Block a user