MSP-4160 update LocalStorage clear when token expires or removes
This commit is contained in:
1 parent
92706e8d99
commit
d4bba909f6
1 file changed
+6
-1
@@ -30,12 +30,17 @@ apiService.interceptors.request.use(
|
|||||||
(error: AxiosError<MSPError>) => Promise.reject(error)
|
(error: AxiosError<MSPError>) => Promise.reject(error)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const localClear = () => {
|
||||||
|
LocalStorage.remove(localStorageKeys.USER_TOKEN)
|
||||||
|
LocalStorage.remove(localStorageKeys.HEADER_NAME)
|
||||||
|
}
|
||||||
|
|
||||||
apiService.interceptors.response.use(
|
apiService.interceptors.response.use(
|
||||||
async (response: any) => response,
|
async (response: any) => response,
|
||||||
(error: AxiosError<MSPError>) => {
|
(error: AxiosError<MSPError>) => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
if (error.response && error.response.status === 401) {
|
if (error.response && error.response.status === 401) {
|
||||||
LocalStorage.clear()
|
localClear()
|
||||||
message.error('Ваша сессия истекла"').then()
|
message.error('Ваша сессия истекла"').then()
|
||||||
LocalStorage.set('redirectUrl', location.pathname)
|
LocalStorage.set('redirectUrl', location.pathname)
|
||||||
window.location.href = routePaths.login
|
window.location.href = routePaths.login
|
||||||
|
|||||||
Reference in new issue
Block a user