Biometrics button on login screen (#18106)
* feat: login with biometry when switching accounts * feat: biometry button on login screen * fix: addressed review comments * fix: biometry button background * ref: moved biometrics constants to main constants file * fix: hide biometric button when not enabled * feat: standard_auth blur prop * fix: leftover rename
This commit is contained in:
parent
bf55a2a974
commit
d0e624afd7
|
@ -6,6 +6,7 @@
|
||||||
[react-native.platform :as platform]
|
[react-native.platform :as platform]
|
||||||
[react-native.touch-id :as touch-id]
|
[react-native.touch-id :as touch-id]
|
||||||
[status-im.common.keychain.events :as keychain]
|
[status-im.common.keychain.events :as keychain]
|
||||||
|
[status-im.constants :as constants]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
@ -46,8 +47,12 @@
|
||||||
{:events [:biometric/show-message]}
|
{:events [:biometric/show-message]}
|
||||||
[_ code]
|
[_ code]
|
||||||
(let [handle-error? (and code
|
(let [handle-error? (and code
|
||||||
(not (contains? #{"USER_CANCELED" "USER_FALLBACK"} code)))
|
(not (contains? #{constants/biometric-error-user-canceled
|
||||||
content (if (#{"NOT_AVAILABLE" "NOT_ENROLLED"} code)
|
constants/biometric-error-user-fallback}
|
||||||
|
code)))
|
||||||
|
content (if (#{constants/biometric-error-not-available
|
||||||
|
constants/biometric-error-not-enrolled}
|
||||||
|
code)
|
||||||
(i18n/label :t/grant-face-id-permissions)
|
(i18n/label :t/grant-face-id-permissions)
|
||||||
(i18n/label :t/biometric-auth-error {:code code}))]
|
(i18n/label :t/biometric-auth-error {:code code}))]
|
||||||
(when handle-error?
|
(when handle-error?
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
(rf/dispatch [:set-in [:profile/login :error] ""]))
|
(rf/dispatch [:set-in [:profile/login :error] ""]))
|
||||||
|
|
||||||
(defn- view-internal
|
(defn- view-internal
|
||||||
[{:keys [default-password theme shell? on-press-biometrics]}]
|
[{:keys [default-password theme shell? on-press-biometrics blur?]}]
|
||||||
(let [{:keys [error processing]} (rf/sub [:profile/login])
|
(let [{:keys [error processing]} (rf/sub [:profile/login])
|
||||||
error-message (get-error-message error)
|
error-message (get-error-message error)
|
||||||
error? (boolean (seq error-message))]
|
error? (boolean (seq error-message))]
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
[quo/input
|
[quo/input
|
||||||
{:container-style {:flex 1}
|
{:container-style {:flex 1}
|
||||||
:type :password
|
:type :password
|
||||||
:blur? true
|
:blur? blur?
|
||||||
:disabled? processing
|
:disabled? processing
|
||||||
:placeholder (i18n/label :t/type-your-password)
|
:placeholder (i18n/label :t/type-your-password)
|
||||||
:auto-focus true
|
:auto-focus true
|
||||||
|
@ -49,6 +49,7 @@
|
||||||
{:container-style style/auth-button
|
{:container-style style/auth-button
|
||||||
:on-press on-press-biometrics
|
:on-press on-press-biometrics
|
||||||
:icon-only? true
|
:icon-only? true
|
||||||
|
:background (when blur? :blur)
|
||||||
:type :outline}
|
:type :outline}
|
||||||
:i/face-id])]
|
:i/face-id])]
|
||||||
(when error?
|
(when error?
|
||||||
|
|
|
@ -375,6 +375,11 @@
|
||||||
(def ^:const auth-method-biometric-prepare "biometric-prepare")
|
(def ^:const auth-method-biometric-prepare "biometric-prepare")
|
||||||
(def ^:const auth-method-none "none")
|
(def ^:const auth-method-none "none")
|
||||||
|
|
||||||
|
(def ^:const biometric-error-user-canceled "USER_CANCELED")
|
||||||
|
(def ^:const biometric-error-user-fallback "USER_USER_FALLBACK")
|
||||||
|
(def ^:const biometric-error-not-available "NOT_AVAILABLE")
|
||||||
|
(def ^:const biometric-error-not-enrolled "NOT_ENROLLED")
|
||||||
|
|
||||||
(def ^:const onboarding-generating-keys-animation-duration-ms 7000)
|
(def ^:const onboarding-generating-keys-animation-duration-ms 7000)
|
||||||
(def ^:const onboarding-generating-keys-navigation-retry-ms 3000)
|
(def ^:const onboarding-generating-keys-navigation-retry-ms 3000)
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
[status-im.common.log :as logging]
|
[status-im.common.log :as logging]
|
||||||
[status-im.common.universal-links :as universal-links]
|
[status-im.common.universal-links :as universal-links]
|
||||||
[status-im.config :as config]
|
[status-im.config :as config]
|
||||||
|
[status-im.constants :as constants]
|
||||||
[status-im.contexts.chat.messages.link-preview.events :as link-preview]
|
[status-im.contexts.chat.messages.link-preview.events :as link-preview]
|
||||||
[status-im.contexts.contacts.events :as contacts]
|
[status-im.contexts.contacts.events :as contacts]
|
||||||
[status-im.contexts.profile.config :as profile.config]
|
[status-im.contexts.profile.config :as profile.config]
|
||||||
|
@ -220,8 +221,7 @@
|
||||||
(fn [{:keys [db]} [code]]
|
(fn [{:keys [db]} [code]]
|
||||||
(let [key-uid (get-in db [:profile/login :key-uid])]
|
(let [key-uid (get-in db [:profile/login :key-uid])]
|
||||||
{:db db
|
{:db db
|
||||||
:fx [[:dispatch [:init-root :profiles]]
|
:fx [(if (= code constants/biometric-error-not-enrolled)
|
||||||
(if (= code "NOT_ENROLLED")
|
|
||||||
[:biometric/supress-not-enrolled-error
|
[:biometric/supress-not-enrolled-error
|
||||||
[key-uid
|
[key-uid
|
||||||
[:biometric/show-message code]]]
|
[:biometric/show-message code]]]
|
||||||
|
|
|
@ -124,6 +124,8 @@
|
||||||
:on-card-press (fn []
|
:on-card-press (fn []
|
||||||
(rf/dispatch
|
(rf/dispatch
|
||||||
[:profile/profile-selected key-uid])
|
[:profile/profile-selected key-uid])
|
||||||
|
(rf/dispatch
|
||||||
|
[:profile.login/login-with-biometric-if-available key-uid])
|
||||||
(when-not keycard-pairing (set-hide-profiles)))}]))
|
(when-not keycard-pairing (set-hide-profiles)))}]))
|
||||||
|
|
||||||
(defn- f-profiles-section
|
(defn- f-profiles-section
|
||||||
|
@ -171,6 +173,7 @@
|
||||||
{:keys [key-uid name customization-color]} (rf/sub [:profile/login-profile])
|
{:keys [key-uid name customization-color]} (rf/sub [:profile/login-profile])
|
||||||
sign-in-enabled? (rf/sub [:sign-in-enabled?])
|
sign-in-enabled? (rf/sub [:sign-in-enabled?])
|
||||||
profile-picture (rf/sub [:profile/login-profiles-picture key-uid])
|
profile-picture (rf/sub [:profile/login-profiles-picture key-uid])
|
||||||
|
auth-method (rf/sub [:auth-method])
|
||||||
login-multiaccount #(rf/dispatch [:profile.login/login])]
|
login-multiaccount #(rf/dispatch [:profile.login/login])]
|
||||||
[rn/keyboard-avoiding-view
|
[rn/keyboard-avoiding-view
|
||||||
{:style style/login-container
|
{:style style/login-container
|
||||||
|
@ -206,8 +209,17 @@
|
||||||
:profile-picture profile-picture
|
:profile-picture profile-picture
|
||||||
:card-style style/login-profile-card}]
|
:card-style style/login-profile-card}]
|
||||||
[standard-authentication/password-input
|
[standard-authentication/password-input
|
||||||
{:shell? true
|
{:shell? true
|
||||||
:default-password password}]]
|
:blur? true
|
||||||
|
:on-press-biometrics (when (= auth-method constants/auth-method-biometric)
|
||||||
|
(fn []
|
||||||
|
(rf/dispatch [:biometric/authenticate
|
||||||
|
{:on-success #(rf/dispatch
|
||||||
|
[:profile.login/biometric-success])
|
||||||
|
:on-fail #(rf/dispatch
|
||||||
|
[:profile.login/biometric-auth-fail
|
||||||
|
%])}])))
|
||||||
|
:default-password password}]]
|
||||||
[quo/button
|
[quo/button
|
||||||
{:size 40
|
{:size 40
|
||||||
:type :primary
|
:type :primary
|
||||||
|
|
Loading…
Reference in New Issue