diff --git a/modules/hybrid-app/android/src/main/java/com/expensify/reactnativehybridapp/ReactNativeHybridApp.kt b/modules/hybrid-app/android/src/main/java/com/expensify/reactnativehybridapp/ReactNativeHybridApp.kt index c72554acf9f53..179ab64238df5 100644 --- a/modules/hybrid-app/android/src/main/java/com/expensify/reactnativehybridapp/ReactNativeHybridApp.kt +++ b/modules/hybrid-app/android/src/main/java/com/expensify/reactnativehybridapp/ReactNativeHybridApp.kt @@ -70,4 +70,12 @@ class ReactNativeHybridApp(reactContext: ReactApplicationContext) : override fun clearOldDotAfterSignOut() { Log.d(NAME, "`clearOldDotAfterSignOut` should never be called in standalone `New Expensify` app") } + + override fun startSignOut(){ + Log.d(NAME, "`startSignOut` should never be called in standalone `New Expensify` app") + } + + override fun cancelSignOut(){ + Log.d(NAME, "`cancelSignOut` should never be called in standalone `New Expensify` app") + } } diff --git a/modules/hybrid-app/ios/ReactNativeHybridApp.mm b/modules/hybrid-app/ios/ReactNativeHybridApp.mm index bd89f327cb856..83a2f40ded10f 100644 --- a/modules/hybrid-app/ios/ReactNativeHybridApp.mm +++ b/modules/hybrid-app/ios/ReactNativeHybridApp.mm @@ -51,6 +51,14 @@ - (void)signOutFromOldDot { NSLog(@"[ReactNativeHybridApp] `signOutFromOldDot` should never be called in standalone `New Expensify` app"); } +- (void)startSignOut { + NSLog(@"[ReactNativeHybridApp] `startSignOut` should never be called in standalone `New Expensify` app"); +} + +- (void)cancelSignOut { + NSLog(@"[ReactNativeHybridApp] `cancelSignOut` should never be called in standalone `New Expensify` app"); +} + - (void)clearOldDotAfterSignOut { NSLog(@"[ReactNativeHybridApp] `clearOldDotAfterSignOut` should never be called in standalone `New Expensify` app"); } diff --git a/modules/hybrid-app/src/NativeReactNativeHybridApp.ts b/modules/hybrid-app/src/NativeReactNativeHybridApp.ts index 22ff014f9cfdf..add610058d19a 100644 --- a/modules/hybrid-app/src/NativeReactNativeHybridApp.ts +++ b/modules/hybrid-app/src/NativeReactNativeHybridApp.ts @@ -14,6 +14,8 @@ export interface Spec extends TurboModule { onURLListenerAdded: () => void; signInToOldDot: (autoGeneratedLogin: string, autoGeneratedPassword: string, authToken: string, email: string, policyID: string, signingInWithSAML?: boolean) => void; signOutFromOldDot: () => void; + startSignOut: () => void; + cancelSignOut: () => void; clearOldDotAfterSignOut: () => void; } diff --git a/modules/hybrid-app/src/index.native.ts b/modules/hybrid-app/src/index.native.ts index 2fb56b8321c15..4163cb58246f6 100644 --- a/modules/hybrid-app/src/index.native.ts +++ b/modules/hybrid-app/src/index.native.ts @@ -35,6 +35,12 @@ const HybridAppModule: HybridAppModuleType = { signOutFromOldDot() { ReactNativeHybridApp.signOutFromOldDot(); }, + startSignOut() { + ReactNativeHybridApp.startSignOut(); + }, + cancelSignOut() { + ReactNativeHybridApp.cancelSignOut(); + }, clearOldDotAfterSignOut() { ReactNativeHybridApp.clearOldDotAfterSignOut(); }, diff --git a/modules/hybrid-app/src/index.ts b/modules/hybrid-app/src/index.ts index 6e0534d37d4b6..6c6df50ddb41d 100644 --- a/modules/hybrid-app/src/index.ts +++ b/modules/hybrid-app/src/index.ts @@ -46,6 +46,14 @@ const HybridAppModule: HybridAppModuleType = { // eslint-disable-next-line no-console console.warn('HybridAppModule: `signOutFromOldDot` should never be called on web'); }, + startSignOut() { + // eslint-disable-next-line no-console + console.warn('HybridAppModule: `startSignOut` should never be called on web'); + }, + cancelSignOut() { + // eslint-disable-next-line no-console + console.warn('HybridAppModule: `cancelSignOut` should never be called on web'); + }, clearOldDotAfterSignOut() { // eslint-disable-next-line no-console console.warn('HybridAppModule: `clearOldDotAfterSignOut` should never be called on web'); diff --git a/modules/hybrid-app/src/types.ts b/modules/hybrid-app/src/types.ts index f5ca552309be2..3a8c5ec0a4997 100644 --- a/modules/hybrid-app/src/types.ts +++ b/modules/hybrid-app/src/types.ts @@ -10,6 +10,8 @@ type HybridAppModuleType = { onURLListenerAdded: () => void; signInToOldDot: (args: {autoGeneratedLogin: string; autoGeneratedPassword: string; authToken: string; email: string; policyID: string; signingInWithSAML?: boolean}) => void; signOutFromOldDot: () => void; + startSignOut: () => void; + cancelSignOut: () => void; clearOldDotAfterSignOut: () => void; }; diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index 7ebdac9a989fc..58a1e55dda20a 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -265,6 +265,9 @@ function callSAMLSignOut(params: LogOutParams, authToken: string): Promise { if (result && result.type !== 'success') { + if (CONFIG.IS_HYBRID_APP) { + HybridAppModule.cancelSignOut(); + } return Promise.reject(Error('Logout cancelled')); } // We always want to sign out the user from the app @@ -339,6 +342,10 @@ function signOutAndRedirectToSignIn(shouldResetToHome?: boolean, shouldStashSess const isSupportal = isSupportAuthToken(); const shouldRestoreStashedSession = isSupportal || shouldForceUseStashedSession; + if (CONFIG.IS_HYBRID_APP && shouldSignOutFromOldDot) { + HybridAppModule.startSignOut(); + } + // We'll only call signOut if we're not stashing the session and not restoring a stashed session, // otherwise we'll call the API to invalidate the autogenerated credentials used for infinite // session.