Skip to content

Commit

Permalink
fix: prevent user from going back during PIN set flow
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed May 6, 2024
1 parent 13cc008 commit 9e6263f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
21 changes: 17 additions & 4 deletions src/screens/Settings/PIN/AskForBiometrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,21 @@ const AskForBiometrics = ({

const onSkip = (): void => {
const bioType = biometryData?.biometryType ?? 'Biometrics';
navigation.navigate('Result', { bio: false, type: bioType });
// use navigation.reset to prevent user from going back to previous screen
navigation.reset({
index: 0,
routes: [{ name: 'Result', params: { bio: false, type: bioType } }],
});
};

const onContinue = useCallback((): void => {
const bioType = biometryData?.biometryType ?? 'Biometrics';

if (!biometryData?.available || !shouldEnableBiometrics) {
navigation.navigate('Result', { bio: false, type: bioType });
navigation.reset({
index: 0,
routes: [{ name: 'Result', params: { bio: false, type: bioType } }],
});
return;
}

Expand All @@ -81,7 +88,10 @@ const AskForBiometrics = ({
.then(({ success }) => {
if (success) {
dispatch(updateSettings({ biometrics: true }));
navigation.navigate('Result', { bio: true, type: bioType });
navigation.reset({
index: 0,
routes: [{ name: 'Result', params: { bio: true, type: bioType } }],
});
}
})
.catch(() => {
Expand All @@ -103,7 +113,10 @@ const AskForBiometrics = ({

return (
<GradientView style={styles.root}>
<BottomSheetNavigationHeader title={biometricsName} />
<BottomSheetNavigationHeader
title={biometricsName}
displayBackButton={false}
/>

<View style={styles.content}>
{!biometryData && <BodyM color="white50">{t('bio_loading')}</BodyM>}
Expand Down
6 changes: 5 additions & 1 deletion src/screens/Settings/PIN/ChoosePIN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ const ChoosePIN = ({
if (pinsAreEqual) {
addPin(pin);
dispatch(hideTodo(pinTodo.id));
navigation.navigate('AskForBiometrics');
// replace the navigation stack to avoid going back to the PIN screen
navigation.reset({
index: 0,
routes: [{ name: 'AskForBiometrics' }],
});
} else {
vibrate({ type: 'notificationWarning' });
setPin('');
Expand Down

0 comments on commit 9e6263f

Please sign in to comment.