From 34b9a477bbfcdcf18c44e5e9063cf062e7e9e672 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Sat, 7 Oct 2017 11:18:16 -0500 Subject: [PATCH] Fingerprint updates --- src/screens/Authenticate.js | 41 +++++++++++++++++-------- vendor/react-native-fingerprint-scanner | 2 +- vendor/sn-textview/src/TextView.js | 3 +- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/screens/Authenticate.js b/src/screens/Authenticate.js index 21cd26b4..cc198a8d 100644 --- a/src/screens/Authenticate.js +++ b/src/screens/Authenticate.js @@ -149,12 +149,23 @@ export default class Authenticate extends Abstract { {isAuthenticating && this.authProps.fingerprint && - + } {((isAuthenticating && this.authProps.passcode) || isSetup) && - + } @@ -397,19 +408,22 @@ class FingerprintSection extends Abstract { this.beginAuthentication(); } else { if(this.isMounted()) { - this.setState({ error: error.message, began: false}); + this.setState({ error: "Authentication failed. Tap to try again.", began: false}); } } }); } else { - FingerprintScanner.authenticate({fallbackEnabled: false, description: 'Fingerprint is required to access your notes.' }) + // iOS + FingerprintScanner.authenticate({fallbackEnabled: true, description: 'Fingerprint is required to access your notes.' }) .then(() => { this.handleSuccessfulAuth(); }) .catch((error) => { console.log("Error:", error); - if(this.isMounted()) { - this.setState({ error: error.message, began: false }); + if(error.name == "UserCancel") { + this.mergeState({ began: false }); + } else if(this.isMounted()) { + this.mergeState({ error: "Authentication failed. Tap to try again.", began: false }); } }); } @@ -435,10 +449,13 @@ class FingerprintSection extends Abstract { } onPress = () => { - if(!this.props.began) { + if(__DEV__) { + this.__dev_simulateSuccess(); + return; + } + + if(!this.state.began) { this.props.onPress(); - } else { - __DEV__ && this.__dev_simulateSuccess(); } } @@ -454,8 +471,7 @@ class FingerprintSection extends Abstract { var text; if(this.state.began) { text = "Please scan your fingerprint"; - } - else if(!this.props.began) { + } else { text = "Tap here to begin authentication."; } @@ -473,6 +489,7 @@ class FingerprintSection extends Abstract {