From 4ff73a8a6a12e7d6416710dae2b3b509a3715cc0 Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Fri, 31 May 2024 13:13:00 +0530 Subject: [PATCH] Show proper error when bio metric fails (#20233) --- src/react_native/biometrics.cljs | 7 +++++-- src/status_im/common/biometric/events.cljs | 10 +++++++--- translations/en.json | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/react_native/biometrics.cljs b/src/react_native/biometrics.cljs index 6963640642..c6682baf42 100644 --- a/src/react_native/biometrics.cljs +++ b/src/react_native/biometrics.cljs @@ -8,6 +8,8 @@ (def ^:private ^:const android-not-available-error-message "Biometric hardware unavailable") (def ^:private ^:const android-not-enrolled-error-message "No fingerprints enrolled.") +(def ^:private ^:const android-too-many-attempts-error-message + "Too many attempts. Use screen lock instead.") (def ^:private ^:const ios-not-enrolled-error-message "No identities are enrolled") (defn get-supported-type @@ -39,8 +41,9 @@ [message] (let [cause (if platform/android? (condp = message - android-not-enrolled-error-message :biometrics/not-enrolled-error - android-not-available-error-message :biometrics/not-available-error + android-not-enrolled-error-message :biometrics/not-enrolled-error + android-not-available-error-message :biometrics/not-available-error + android-too-many-attempts-error-message :biometric/too-many-attempts :biometrics/unknown-error) (condp #(string/includes? %2 %1) message diff --git a/src/status_im/common/biometric/events.cljs b/src/status_im/common/biometric/events.cljs index 93caf5a50d..a8b8ea67e9 100644 --- a/src/status_im/common/biometric/events.cljs +++ b/src/status_im/common/biometric/events.cljs @@ -13,10 +13,14 @@ (defn show-message [_ [code]] - (let [content (if (#{:biometrics/not-enrolled-error - :biometrics/not-available-error} - code) + (let [content (case code + (:biometrics/not-enrolled-error + :biometrics/not-available-error) (i18n/label :t/grant-face-id-permissions) + + :biometric/too-many-attempts + (i18n/label :t/biometric-too-many-attempts) + (i18n/label :t/biometric-auth-error {:code code}))] {:fx [[:effects.utils/show-popup {:title (i18n/label :t/biometric-auth-login-error-title) diff --git a/translations/en.json b/translations/en.json index 4bb23a9146..2e698dbdf4 100644 --- a/translations/en.json +++ b/translations/en.json @@ -91,6 +91,7 @@ "biometric-enable-button": "Enable {{bio-type-label}}", "biometric-fingerprint": "Fingerprint", "biometric-faceid": "Face ID", + "biometric-too-many-attempts": "Too many attempts. Enter the password manually or try again after some time", "biometric-touchid": "Touch ID", "blank-keycard-text": "You can proceed with your keycard once you've generated your keys and name", "blank-keycard-title": "Looks like you’ve tapped \na blank keycard",