diff --git a/src/auth/index.js b/src/auth/index.js index 83717ba..b053a3e 100644 --- a/src/auth/index.js +++ b/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) }