|
|
|
@ -1,12 +1,13 @@ |
|
|
|
import { PAGES } from 'config' |
|
|
|
import { PAGES } from 'config' |
|
|
|
import { removeToken } from 'helpers' |
|
|
|
import { removeToken } from 'helpers' |
|
|
|
|
|
|
|
|
|
|
|
export const logoutIfUnauthorized = (error: Error) => { |
|
|
|
export const logoutIfUnauthorized = (response: Response) => { |
|
|
|
if (error.message === 'Unauthorized') { |
|
|
|
if (response.status === 401 || response.status === 403) { |
|
|
|
removeToken() |
|
|
|
removeToken() |
|
|
|
window.location.pathname = PAGES.login |
|
|
|
window.location.pathname = PAGES.login |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const error = new Error(response.statusText) |
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.error(error) |
|
|
|
console.error(error) |
|
|
|
return Promise.reject(error) |
|
|
|
return Promise.reject(error) |
|
|
|
|