MSP-4160 update LocalStorage clear when token expires or removes

This commit is contained in:
Anastasiia committed 2024-10-02 11:20:16 +03:00
1 parent 92706e8d99
commit d4bba909f6
1 file changed
+6 -1
+6 -1
View File
@@ -30,12 +30,17 @@ apiService.interceptors.request.use(
(error: AxiosError<MSPError>) => Promise.reject(error)
)
const localClear = () => {
LocalStorage.remove(localStorageKeys.USER_TOKEN)
LocalStorage.remove(localStorageKeys.HEADER_NAME)
}
apiService.interceptors.response.use(
async (response: any) => response,
(error: AxiosError<MSPError>) => {
console.error(error)
if (error.response && error.response.status === 401) {
LocalStorage.clear()
localClear()
message.error('Ваша сессия истекла"').then()
LocalStorage.set('redirectUrl', location.pathname)
window.location.href = routePaths.login