Skip to content

Commit

Permalink
block sign in logic when OD sign-in was performed
Browse files Browse the repository at this point in the history
  • Loading branch information
war-in committed Dec 6, 2024
1 parent 39e1fe1 commit 6f5d0c7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/libs/HybridApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ function handleChangeInHybridAppSignInFlow(hybridApp: OnyxEntry<HybridApp>, tryN
return;
}

if (hybridApp?.newDotSignInState === CONST.HYBRID_APP_SIGN_IN_STATE.FINISHED && tryNewDot !== undefined && !!credentials?.autoGeneratedLogin && !!credentials?.autoGeneratedPassword) {
if (
hybridApp?.newDotSignInState === CONST.HYBRID_APP_SIGN_IN_STATE.FINISHED &&
!hybridApp?.signedInOnOldDot &&
tryNewDot !== undefined &&
!!credentials?.autoGeneratedLogin &&
!!credentials?.autoGeneratedPassword
) {
Log.info(`[HybridApp] Performing sign-in${shouldUseOldApp(tryNewDot) ? '' : ' (in background)'} on OldDot side`);
NativeModules.HybridAppModule.signInToOldDot(
credentials.autoGeneratedLogin,
Expand All @@ -78,6 +84,7 @@ function handleChangeInHybridAppSignInFlow(hybridApp: OnyxEntry<HybridApp>, tryN
getCurrentUserEmail() ?? '',
activePolicyID ?? '',
);
HybridAppActions.setSignedInOnOldDot(true);

if (shouldUseOldApp(tryNewDot)) {
HybridAppActions.setUseNewDotSignInPage(false).then(() => {
Expand Down
8 changes: 7 additions & 1 deletion src/libs/actions/HybridApp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ function setUseNewDotSignInPage(useNewDotSignInPage: boolean) {
return Onyx.merge(ONYXKEYS.HYBRID_APP, {useNewDotSignInPage});
}

function setSignedInOnOldDot(signedInOnOldDot: boolean) {
Onyx.merge(ONYXKEYS.HYBRID_APP, {signedInOnOldDot});
}

/*
* Starts HybridApp sign-in flow from the beginning.
*/
function resetSignInFlow() {
Onyx.merge(ONYXKEYS.HYBRID_APP, {
readyToShowAuthScreens: false,
newDotSignInState: CONST.HYBRID_APP_SIGN_IN_STATE.NOT_STARTED,
signedInOnOldDot: false,
});
}

Expand All @@ -49,6 +54,7 @@ function prepareHybridAppAfterTransitionToNewDot(hybridApp: HybridApp) {
...hybridApp,
readyToShowAuthScreens: false,
newDotSignInState: CONST.HYBRID_APP_SIGN_IN_STATE.NOT_STARTED,
signedInOnOldDot: false,
});
}

Expand All @@ -59,4 +65,4 @@ function prepareHybridAppAfterTransitionToNewDot(hybridApp: HybridApp) {
});
}

export {parseHybridAppSettings, setReadyToShowAuthScreens, setNewDotSignInState, resetSignInFlow, prepareHybridAppAfterTransitionToNewDot, setUseNewDotSignInPage};
export {parseHybridAppSettings, setReadyToShowAuthScreens, setNewDotSignInState, resetSignInFlow, prepareHybridAppAfterTransitionToNewDot, setUseNewDotSignInPage, setSignedInOnOldDot};
5 changes: 4 additions & 1 deletion src/types/onyx/HybridApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ type HybridApp = {
/** States whether we transitioned from OldDot to show only certain group of screens */
isSingleNewDotEntry?: boolean;

/** stores infromation if last log out was performed from OldDot */
/** Stores information if last log out was performed from OldDot */
loggedOutFromOldDot?: boolean;

/** */
shouldRemoveDelegatedAccess?: boolean;

/** Describes current stage of NewDot sign-in */
newDotSignInState?: ValueOf<typeof CONST.HYBRID_APP_SIGN_IN_STATE>;

/** Tells if OldDot sign-in was performed */
signedInOnOldDot?: boolean;
};

export default HybridApp;

0 comments on commit 6f5d0c7

Please sign in to comment.