Преглед на файлове

update auth for 401 and 500

master
Alex Cheung преди 1 година
родител
ревизия
9bd2d64d4b
променени са 1 файла, в които са добавени 31 реда и са изтрити 47 реда
  1. +31
    -47
      src/auth/index.js

+ 31
- 47
src/auth/index.js Целия файл

@@ -160,55 +160,39 @@ export const SetupAxiosInterceptors = () => {
throw refreshError;
});
} else {
if (isUserLoggedIn()){
if (error.response.status === 401) {
if (localStorage.getItem("expiredAlertShown") === null) {
localStorage.setItem("expiredAlertShown", true)
alert("登入驗證已過期,請重新登入。")
}
}
// ** if (status === 401) {
// if (response.status === 401) {
// if (localStorage.getItem("expiredAlertShown") === null) {
// localStorage.setItem("expiredAlertShown", true)
// alert("登入驗證已過期,請重新登入。")
// }
// }
// if (response && response.status === 401) {
// if (localStorage.getItem("expiredAlertShown") === null) {
// localStorage.setItem("expiredAlertShown", true)
// alert("登入驗證已過期,請重新登入。")
// }
// }

if (error.response.status === 500) {
// await dispatch(handleLogoutFunction());
// await navigate('/login');
// await window.location.reload();
}
if (localStorage.getItem("expiredAlertShown")) {
await dispatch(handleLogoutFunction());
await navigate('/login');
await window.location.reload();
}

// console.log(error)

} else {
if (error.response.status === 401) {
await dispatch(handleLogoutFunction());
await navigate('/login');
// await window.location.reload();
}
if (error.response.status === 401) {
await dispatch(handleLogoutFunction());
await navigate('/login');
await window.location.reload();
}

// ** if (status === 401) {
// if (response.status === 401) {
// if (localStorage.getItem("expiredAlertShown") === null) {
// localStorage.setItem("expiredAlertShown", true)
// alert("登入驗證已過期,請重新登入。")
// }
// }
// if (response && response.status === 401) {
// if (localStorage.getItem("expiredAlertShown") === null) {
// localStorage.setItem("expiredAlertShown", true)
// alert("登入驗證已過期,請重新登入。")
// }
// }
// if (localStorage.getItem("expiredAlertShown")) {
// await dispatch(handleLogoutFunction());
// await navigate('/login');
// await window.location.reload();
// }

if (error.response.status === 500){
//setIsUploading(false);
}
// console.log(error)
}
return Promise.reject(error)
}


Зареждане…
Отказ
Запис