Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: require Biometrics to enable Biometrics #1832

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/components/AuthCheck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}>;
};

/**
Expand All @@ -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 (
<Animated.View style={StyleSheet.absoluteFillObject} exiting={FadeOut}>
<ThemedView style={styles.root}>
<Biometrics
onSuccess={(): void => onSuccess?.()}
onFailure={(): void => setRequireBiometrics(false)}
onFailure={(): void => setBioEnabled(false)}
/>
</ThemedView>
</Animated.View>
Expand All @@ -50,7 +57,7 @@ const AuthCheck = ({
showBackNavigation={showBackNavigation}
showLogoOnPIN={showLogoOnPIN}
allowBiometrics={biometrics && !requirePin}
onShowBiotmetrics={(): void => setRequireBiometrics(true)}
onShowBiotmetrics={(): void => setBioEnabled(true)}
onSuccess={(): void => onSuccess?.()}
/>
</Animated.View>
Expand Down
1 change: 1 addition & 0 deletions src/navigation/settings/SettingsNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export type SettingsStackParamList = {
AuthCheck: {
requirePin?: boolean;
onSuccess: () => void;
requireBiometrics?: boolean;
};
MainSettings: undefined;
GeneralSettings: undefined;
Expand Down
1 change: 1 addition & 0 deletions src/screens/Settings/Security/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ const SecuritySettings = ({
testID: 'UseBiometryInstead',
onPress: (): void => {
navigation.navigate('AuthCheck', {
requireBiometrics: true,
onSuccess: () => {
navigation.pop();
dispatch(updateSettings({ biometrics: !biometrics }));
Expand Down
Loading