- fix: refresh token, codice di errore ...
This commit is contained in:
@@ -6,7 +6,7 @@ import type * as Types from '@src/store/Api/ApiTypes'
|
||||
|
||||
|
||||
// Funzione che smista la richiesta in base al metodo
|
||||
async function sendRequest(url, method, mydata, myformdata, responsedata, options) {
|
||||
async function sendRequest(url, method, mydata, myformdata = null, responsedata = null, options = null) {
|
||||
const actions = {
|
||||
get: () => Api.get(url, mydata, responsedata),
|
||||
post: () => Api.post(url, mydata, responsedata, options),
|
||||
|
||||
@@ -114,9 +114,9 @@ export const Api = {
|
||||
} catch (error) {
|
||||
console.error('Errore durante il refresh token:', error);
|
||||
// Logout dell'utente in caso di errore critico
|
||||
userStore.setAuth('', '');
|
||||
localStorage.removeItem(toolsext.localStorage.token);
|
||||
localStorage.removeItem(toolsext.localStorage.refreshToken);
|
||||
// userStore.setAuth('', '');
|
||||
// localStorage.removeItem(toolsext.localStorage.token);
|
||||
// localStorage.removeItem(toolsext.localStorage.refreshToken);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -147,15 +147,15 @@ export const Api = {
|
||||
|
||||
if (err2?.code === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||
userStore.setServerCode(toolsext.ERR_AUTHENTICATION);
|
||||
// userStore.setAuth('', '');
|
||||
throw { status: toolsext.ERR_RETRY_LOGIN };
|
||||
userStore.setAuth('', '');
|
||||
throw { status: err2.code };
|
||||
}
|
||||
|
||||
// Gestione di altri errori critici
|
||||
throw err2;
|
||||
}
|
||||
} else if (status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||
// userStore.setAuth('', '');
|
||||
userStore.setAuth('', '');
|
||||
const $router = useRouter()
|
||||
throw { status: toolsext.ERR_RETRY_LOGIN };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user