diff --git a/src/helpers/callApi/index.tsx b/src/helpers/callApi/index.tsx index 36770e24..46f47e5c 100644 --- a/src/helpers/callApi/index.tsx +++ b/src/helpers/callApi/index.tsx @@ -2,6 +2,7 @@ import type { CallApiArgs } from './types' import { parseJSON } from './parseJSON' import { checkStatus } from './checkStatus' import { getRequestConfig } from './getRequestConfig' +import { logoutIfUnauthorized } from './logoutIfUnauthorized' export const callApiBase = ({ abortSignal, @@ -38,7 +39,7 @@ const callApiWithTimeout = (args: CallApiArgs) => { }) .then(checkStatus) .then(parseJSON) - // .catch(logoutIfUnauthorized) + .catch(logoutIfUnauthorized) .finally(() => clearTimeout(timeoutId)) } @@ -48,5 +49,5 @@ export const callApi = (args: CallApiArgs) => { return callApiBase(args) .then(checkStatus) .then(parseJSON) - // .catch(logoutIfUnauthorized) + .catch(logoutIfUnauthorized) } diff --git a/src/helpers/callApi/logoutIfUnauthorized.tsx b/src/helpers/callApi/logoutIfUnauthorized.tsx index d7cf61c8..2371f5eb 100644 --- a/src/helpers/callApi/logoutIfUnauthorized.tsx +++ b/src/helpers/callApi/logoutIfUnauthorized.tsx @@ -1,10 +1,9 @@ -import { removeToken } from 'helpers' - export const logoutIfUnauthorized = async (response: Response) => { - if (response.status === 401 || response.status === 403) { - removeToken() - window.dispatchEvent(new Event('FORBIDDEN_REQUEST')) - } + /* отключили из-за доступа без авторизации */ + // if (response.status === 401 || response.status === 403) { + // removeToken() + // window.dispatchEvent(new Event('FORBIDDEN_REQUEST')) + // } const error = new Error(response.statusText) // eslint-disable-next-line no-console