From 34dfd327bb4299deed1f24645b1c3cd3c7d71609 Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Mon, 30 Jan 2023 17:52:56 +0700 Subject: [PATCH] fix(subsriptions stripe): fix stripe subscriptions --- src/helpers/callApi/index.tsx | 5 +++-- src/helpers/callApi/logoutIfUnauthorized.tsx | 11 +++++------ 2 files changed, 8 insertions(+), 8 deletions(-) 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