From 874906b11f50ac90a337bcd0a9ebd880304492b6 Mon Sep 17 00:00:00 2001 From: yqrashawn Date: Thu, 13 Jun 2024 09:28:07 +0800 Subject: [PATCH] fix: face id toggle respect system face id permission (#20227) Signed-off-by: yqrashawn --- src/react_native/biometrics.cljs | 4 ++-- src/status_im/common/biometric/events.cljs | 5 ++++- src/status_im/common/biometric/events_test.cljs | 2 +- .../profile/settings/screens/password/view.cljs | 12 ++++++------ translations/en.json | 1 + 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/react_native/biometrics.cljs b/src/react_native/biometrics.cljs index c6682baf42..189dc89ca8 100644 --- a/src/react_native/biometrics.cljs +++ b/src/react_native/biometrics.cljs @@ -41,13 +41,13 @@ [message] (let [cause (if platform/android? (condp = message - android-not-enrolled-error-message :biometrics/not-enrolled-error + android-not-enrolled-error-message :biometrics/fingerprints-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 - ios-not-enrolled-error-message :biometrics/not-enrolled-error + ios-not-enrolled-error-message :biometrics/ios-not-enrolled-error :biometrics/unknown-error))] (ex-info "Failed to authenticate with biometrics" {:orig-error-message message} diff --git a/src/status_im/common/biometric/events.cljs b/src/status_im/common/biometric/events.cljs index a8b8ea67e9..176a2a31d8 100644 --- a/src/status_im/common/biometric/events.cljs +++ b/src/status_im/common/biometric/events.cljs @@ -14,8 +14,11 @@ (defn show-message [_ [code]] (let [content (case code - (:biometrics/not-enrolled-error + (:biometrics/fingerprints-not-enrolled-error :biometrics/not-available-error) + (i18n/label :t/grant-fingerprints-permissions) + + :biometrics/ios-not-enrolled-error (i18n/label :t/grant-face-id-permissions) :biometric/too-many-attempts diff --git a/src/status_im/common/biometric/events_test.cljs b/src/status_im/common/biometric/events_test.cljs index 9857456120..1837673cb0 100644 --- a/src/status_im/common/biometric/events_test.cljs +++ b/src/status_im/common/biometric/events_test.cljs @@ -18,7 +18,7 @@ (let [cofx {:db {}} expected {:fx [[:effects.utils/show-popup {:title (i18n/label :t/biometric-auth-login-error-title) - :content (i18n/label :t/grant-face-id-permissions)}]]}] + :content (i18n/label :t/grant-fingerprints-permissions)}]]}] (is (match? expected (sut/show-message cofx [:biometrics/not-available-error]))))) diff --git a/src/status_im/contexts/profile/settings/screens/password/view.cljs b/src/status_im/contexts/profile/settings/screens/password/view.cljs index 0f6d27ea49..499e788e45 100644 --- a/src/status_im/contexts/profile/settings/screens/password/view.cljs +++ b/src/status_im/contexts/profile/settings/screens/password/view.cljs @@ -30,18 +30,18 @@ supported? (boolean biometric-type) enabled? (= auth-method constants/auth-method-biometric) biometric-on? (and supported? enabled?) - press-handler (if biometric-on? - (fn [] (rf/dispatch [:biometric/disable])) - (on-press-biometric-enable label theme))] + press-handler (when supported? + (if biometric-on? + (fn [] (rf/dispatch [:biometric/disable])) + (on-press-biometric-enable label theme)))] {:title label :image-props icon :image :icon :blur? true :action :selector - :action-props {:disabled? (not supported?) - :on-change press-handler + :action-props {:on-change press-handler :checked? biometric-on?} - :on-press (when supported? press-handler)})) + :on-press press-handler})) (defn- get-change-password-item [] diff --git a/translations/en.json b/translations/en.json index caa355c369..481ed05ad2 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1629,6 +1629,7 @@ "ok-save-pass": "OK, save password", "lock-app-with": "Lock app with", "grant-face-id-permissions": "To grant the required Face ID permission, please go to your system settings and make sure that Status > Face ID is selected", + "grant-fingerprints-permissions": "To grant the required fingerprints permission, please go to your system settings and make sure that Status > Fingerprints is selected", "request-feature": "Request a feature", "select-account-dapp": "Select the account you wish to use with Dapps", "apply": "Apply",