fix(subsriptions stripe): fix stripe subscriptions

pull/52/head
Andrei Dekterev 3 years ago committed by Gitea
parent 9a6d3cae1b
commit 34dfd327bb
  1. 5
      src/helpers/callApi/index.tsx
  2. 11
      src/helpers/callApi/logoutIfUnauthorized.tsx

@ -2,6 +2,7 @@ import type { CallApiArgs } from './types'
import { parseJSON } from './parseJSON' import { parseJSON } from './parseJSON'
import { checkStatus } from './checkStatus' import { checkStatus } from './checkStatus'
import { getRequestConfig } from './getRequestConfig' import { getRequestConfig } from './getRequestConfig'
import { logoutIfUnauthorized } from './logoutIfUnauthorized'
export const callApiBase = ({ export const callApiBase = ({
abortSignal, abortSignal,
@ -38,7 +39,7 @@ const callApiWithTimeout = (args: CallApiArgs) => {
}) })
.then(checkStatus) .then(checkStatus)
.then(parseJSON) .then(parseJSON)
// .catch(logoutIfUnauthorized) .catch(logoutIfUnauthorized)
.finally(() => clearTimeout(timeoutId)) .finally(() => clearTimeout(timeoutId))
} }
@ -48,5 +49,5 @@ export const callApi = (args: CallApiArgs) => {
return callApiBase(args) return callApiBase(args)
.then(checkStatus) .then(checkStatus)
.then(parseJSON) .then(parseJSON)
// .catch(logoutIfUnauthorized) .catch(logoutIfUnauthorized)
} }

@ -1,10 +1,9 @@
import { removeToken } from 'helpers'
export const logoutIfUnauthorized = async (response: Response) => { export const logoutIfUnauthorized = async (response: Response) => {
if (response.status === 401 || response.status === 403) { /* отключили из-за доступа без авторизации */
removeToken() // if (response.status === 401 || response.status === 403) {
window.dispatchEvent(new Event('FORBIDDEN_REQUEST')) // removeToken()
} // window.dispatchEvent(new Event('FORBIDDEN_REQUEST'))
// }
const error = new Error(response.statusText) const error = new Error(response.statusText)
// eslint-disable-next-line no-console // eslint-disable-next-line no-console

Loading…
Cancel
Save