Browse Source

FIX | Refresh sessions

pull/21/head
Vitalik 9 months ago
parent
commit
1abded2b70
  1. 2
      src/App.tsx
  2. 10
      src/api/auth/requests.ts
  3. 4
      src/api/http.service.ts

2
src/App.tsx

@ -2,7 +2,7 @@ import React, { FC, useEffect } from 'react' @@ -2,7 +2,7 @@ import React, { FC, useEffect } from 'react'
import { Provider } from 'react-redux'
import { Navigation } from './modules/root'
import store from './store'
// import './services/system/reactron.service'
import './services/system/reactron.service'
import { ThemeProvider } from './shared/themes'
// import Orientation from 'react-native-orientation-locker'
import { AppState, LogBox } from 'react-native'

10
src/api/auth/requests.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import http from '../http.service'
import http, { axiosInstance } from '../http.service'
import { ApiResponse } from '../http.types'
import {
IFinishLoginPayload,
@ -23,13 +23,7 @@ export const finishLogin = ( @@ -23,13 +23,7 @@ export const finishLogin = (
export const resetSessionReq = (
params: IRefreshTokenPayload,
): ApiResponse<IAuthSuccessResponse> => {
return http.post<IAuthSuccessResponse>(
'auth/refresh-token',
params,
null,
null,
false,
)
return axiosInstance.post('/app/auth/refresh-token', params)
}
export const signOut = (

4
src/api/http.service.ts

@ -11,7 +11,7 @@ import { UserFingerprintGenerator } from '@/shared/helpers/fingerprint.helper' @@ -11,7 +11,7 @@ import { UserFingerprintGenerator } from '@/shared/helpers/fingerprint.helper'
const store = () => GlobalContainerService.get('store')
const axiosInstance = axios.create({
export const axiosInstance = axios.create({
baseURL: config.baseUrl,
// headers: {
// 'Content-Type': 'application/json',
@ -60,7 +60,7 @@ const request = async <T>( @@ -60,7 +60,7 @@ const request = async <T>(
return request(func, retryCount + 1)
}
if (getErrorCode(e) === 401 && tryAgainOnError) {
if (getErrorCode(e) === 401 && tryAgainOnError && retryCount <= 2) {
await authService.refreshSession()
return (await func()) as any as AxiosResponse
}

Loading…
Cancel
Save