jarden-digital/react-native-pincode

[HOWTO] use this for one-time validation against a server

Closed this issue · 4 comments

I want to authenticate a user with a one-time pin input and send that pin to a server to validate him. If i set status to "choose" the user has to input the pin two times before handleResultEnterPin gets called. Setting the status to "enter" results in TypeError: null is not an object (evaluating 'RNKeychainManager.getInternetCredentialsForServer'). The PIN should not get stored somewhere and always has to be validated by a server on every app start. Reason is that there is a windows tool, which has the functionality to reset or change the PIN for the user.

const RequestPinScreen = memo(({ navigation, route }) => {
    const dispatch = useDispatch();
    const { id } = route.params;

    const handleResultEnterPin = (pin) => {
        dispatch(mitarbeiterActions.authenticate({ mitarbeiterid: id, pin: pin }));
    };

    return (
        <SafeAreaView style={styles.root} edges={['left', 'right']}>
            <PINCode
                status="choose"
                storePin={(pin) => handleResultEnterPin(pin)}
                handleResultEnterPin={(pin) => handleResultEnterPin(pin)}
            />
        </SafeAreaView>
    );
});

Thank you very much!

Hi,

Indeed it'd need to fixed. However it's quite a busy time for us at the moment so if you need this fixed before the next couple of weeks, I'd suggest you open a PR. That'd very appreciated.
If you can't do it, I'll try to have a go at it asap.

Cheers

I tried to fix it in my own copy but wasn't able to. I removed all code that has something to do with Keychain so at least the Typeerror is gone.

I would be happy to help but I think I'm not able to..

@Relax594 I don't know if I'm right, but you can get the same result using endProcessFunction.

const RequestPinScreen = memo(({ navigation, route }) => {
    const dispatch = useDispatch();
    const { id } = route.params;

    const handleResultEnterPin = (pinCode) => {
        dispatch(mitarbeiterActions.authenticate({ mitarbeiterid: id, pin: pinCode }));
    };

    return (
        <SafeAreaView style={styles.root} edges={['left', 'right']}>
            <PINCode
                status="enter"
                endProcessFunction={(pinCode) => handleResultEnterPin(pinCode)}
            />
        </SafeAreaView>
    );
});

Yes but no. The way this repo works does not allow this. It's a bug as stated by @Haskkor