oblador / react-native-keychain

:key: Keychain Access for React Native
MIT License
3.13k stars 516 forks source link

`getGenericPassword` rejects on first failed attempt - Android #317

Open simlrh opened 4 years ago

simlrh commented 4 years ago

As mentioned in a comment on #305 and addressed in #312

On Android, when getting credentials using fingerprint, the promise rejects on the first failed attempt. However, the fingerprint scanner is still visible and accepting further attempts. If the user then successfully scans a fingerprint, the app is not notified, as the promise already rejected.

Expected behaviour: Promise not to reject until the fingerprint scanner reaches the maximum attempt limit and closes. Promise to resolve if the fingerprint scan is successful on the 2nd+ attempt.

cladjules commented 4 years ago

The first issue is because onAuthenticationFailed throws an exception and it shouldn't. In that case, the error is recoverable.

Not throwing the exception slightly improve the behaviour, but it should still retry in some cases.

    /** Called when a biometric is valid but not recognized. */
    @Override
    public void onAuthenticationFailed() {
      super.onAuthenticationFailed();
    }