From 9abe64a2375bd59c281af1fea8bca5fb231047cf Mon Sep 17 00:00:00 2001 From: Ivan Vershigora Date: Wed, 15 May 2024 12:45:14 +0100 Subject: [PATCH] fix: require Biometrics to enable Biometrics --- src/components/AuthCheck.tsx | 17 ++++++++++++----- src/navigation/settings/SettingsNavigator.tsx | 1 + src/screens/Settings/Security/index.tsx | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/AuthCheck.tsx b/src/components/AuthCheck.tsx index e0786304a..d4ed31df4 100644 --- a/src/components/AuthCheck.tsx +++ b/src/components/AuthCheck.tsx @@ -12,8 +12,14 @@ import { biometricsSelector } from '../store/reselect/settings'; type AuthCheckProps = { showBackNavigation?: boolean; showLogoOnPIN?: boolean; - route?: RouteProp<{ params: { requirePin: boolean; onSuccess: () => void } }>; onSuccess?: () => void; + route?: RouteProp<{ + params: { + requirePin?: boolean; + requireBiometrics?: boolean; + onSuccess: () => void; + }; + }>; }; /** @@ -26,18 +32,19 @@ const AuthCheck = ({ onSuccess, }: AuthCheckProps): ReactElement => { const biometrics = useAppSelector(biometricsSelector); - const [requireBiometrics, setRequireBiometrics] = useState(biometrics); + const [bioEnabled, setBioEnabled] = useState(biometrics); const requirePin = route?.params?.requirePin ?? false; + const requireBiometrics = route?.params?.requireBiometrics ?? false; onSuccess = route?.params?.onSuccess ?? onSuccess; - if (requireBiometrics && !requirePin) { + if ((bioEnabled && !requirePin) || requireBiometrics) { return ( onSuccess?.()} - onFailure={(): void => setRequireBiometrics(false)} + onFailure={(): void => setBioEnabled(false)} /> @@ -50,7 +57,7 @@ const AuthCheck = ({ showBackNavigation={showBackNavigation} showLogoOnPIN={showLogoOnPIN} allowBiometrics={biometrics && !requirePin} - onShowBiotmetrics={(): void => setRequireBiometrics(true)} + onShowBiotmetrics={(): void => setBioEnabled(true)} onSuccess={(): void => onSuccess?.()} /> diff --git a/src/navigation/settings/SettingsNavigator.tsx b/src/navigation/settings/SettingsNavigator.tsx index 32ead847f..a7220dadb 100644 --- a/src/navigation/settings/SettingsNavigator.tsx +++ b/src/navigation/settings/SettingsNavigator.tsx @@ -65,6 +65,7 @@ export type SettingsStackParamList = { AuthCheck: { requirePin?: boolean; onSuccess: () => void; + requireBiometrics?: boolean; }; MainSettings: undefined; GeneralSettings: undefined; diff --git a/src/screens/Settings/Security/index.tsx b/src/screens/Settings/Security/index.tsx index cce0a188d..351afc0b5 100644 --- a/src/screens/Settings/Security/index.tsx +++ b/src/screens/Settings/Security/index.tsx @@ -190,6 +190,7 @@ const SecuritySettings = ({ testID: 'UseBiometryInstead', onPress: (): void => { navigation.navigate('AuthCheck', { + requireBiometrics: true, onSuccess: () => { navigation.pop(); dispatch(updateSettings({ biometrics: !biometrics }));