Skip to content

Commit 8ba3bd2

Browse files
committed
fix: Dismiss MFA modal directly when scenario context is lost after app restart
1 parent 7c6b9fc commit 8ba3bd2

File tree

1 file changed

+9
-2
lines changed
  • src/components/MultifactorAuthentication/Context

1 file changed

+9
-2
lines changed

src/components/MultifactorAuthentication/Context/Main.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,21 @@ function MultifactorAuthenticationContextProvider({children}: MultifactorAuthent
437437
* Sets an error state which triggers navigation to the failure outcome.
438438
*/
439439
const cancel = useCallback(() => {
440-
// Set error to trigger failure navigation
440+
// When the app is reopened (e.g. page refresh on web), the MFA context resets to its default state
441+
// and scenario becomes undefined. Without a scenario, the state machine in process() won't run,
442+
// so dispatching SET_ERROR would have no effect. In this case we dismiss the modal directly.
443+
if (!state.scenario) {
444+
Navigation.dismissModal();
445+
return;
446+
}
447+
441448
dispatch({
442449
type: 'SET_ERROR',
443450
payload: {
444451
reason: CONST.MULTIFACTOR_AUTHENTICATION.REASON.EXPO.CANCELED,
445452
},
446453
});
447-
}, [dispatch]);
454+
}, [dispatch, state.scenario]);
448455

449456
const contextValue: MultifactorAuthenticationContextValue = useMemo(
450457
() => ({

0 commit comments

Comments
 (0)