Browse Source

FIX | Refresh session

pull/18/head
Vitalik 9 months ago
parent
commit
a3bee27378
  1. 2
      android/app/build.gradle
  2. 6
      ios/taskme2.xcodeproj/project.pbxproj
  3. 2
      src/App.tsx
  4. 8
      src/api/auth/requests.ts
  5. 25
      src/services/domain/auth.service.ts

2
android/app/build.gradle

@ -25,7 +25,7 @@ android { @@ -25,7 +25,7 @@ android {
applicationId "com.app.task_me"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 216
versionCode 217
versionName "2.3"
resValue "string", "build_config_package", "com.app.task_me"
}

6
ios/taskme2.xcodeproj/project.pbxproj

@ -726,7 +726,7 @@ @@ -726,7 +726,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = taskme2/taskme2Stage.Release.entitlements;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 12;
DEVELOPMENT_TEAM = HQ3J3TDPR2;
INFOPLIST_FILE = taskme2/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Task me ;)";
@ -905,7 +905,7 @@ @@ -905,7 +905,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = taskme2/taskme2.entitlements;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 12;
DEVELOPMENT_TEAM = VCUZPZ9254;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = taskme2/Info.plist;
@ -942,7 +942,7 @@ @@ -942,7 +942,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = taskme2/taskme2.entitlements;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 12;
DEVELOPMENT_TEAM = VCUZPZ9254;
INFOPLIST_FILE = taskme2/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Task me ;)";

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'

8
src/api/auth/requests.ts

@ -23,7 +23,13 @@ export const finishLogin = ( @@ -23,7 +23,13 @@ export const finishLogin = (
export const resetSessionReq = (
params: IRefreshTokenPayload,
): ApiResponse<IAuthSuccessResponse> => {
return http.post<IAuthSuccessResponse>('auth/refresh-token', params)
return http.post<IAuthSuccessResponse>(
'auth/refresh-token',
params,
null,
null,
false,
)
}
export const signOut = (

25
src/services/domain/auth.service.ts

@ -160,18 +160,23 @@ const dropTokens = async () => { @@ -160,18 +160,23 @@ const dropTokens = async () => {
}
const refreshSession = async (refreshToken?: string) => {
let token = refreshToken
if (!token) {
const existTokens = await getTokensFromStore()
token = existTokens?.refreshToken
}
try {
let token = refreshToken
if (!token) {
const existTokens = await getTokensFromStore()
token = existTokens?.refreshToken
}
if (!token) return
if (!token) throw new Error('Refresh token isnt exist')
const { data } = await resetSessionReq({
refreshToken: token,
})
await saveTokens(data)
const { data } = await resetSessionReq({
refreshToken: token,
})
await saveTokens(data)
} catch (e) {
console.log('Error refresh session')
throw e
}
}
const getTokensFromStore = async () => {

Loading…
Cancel
Save