From 07e0064d6830ddff39faabc10e04d7cb8d025ca3 Mon Sep 17 00:00:00 2001 From: Milad Date: Mon, 19 Feb 2024 16:17:42 +0330 Subject: [PATCH] update enter_password usage on profile --- .../contexts/profile/profiles/view.cljs | 110 +++++++++++------- 1 file changed, 66 insertions(+), 44 deletions(-) diff --git a/src/status_im/contexts/profile/profiles/view.cljs b/src/status_im/contexts/profile/profiles/view.cljs index b6aa3a39fb..f5c40cf744 100644 --- a/src/status_im/contexts/profile/profiles/view.cljs +++ b/src/status_im/contexts/profile/profiles/view.cljs @@ -16,6 +16,7 @@ [utils.debounce :as debounce] [utils.i18n :as i18n] [utils.re-frame :as rf] + [utils.security.core :as security] [utils.transforms :as transforms])) (defonce push-animation-fn-atom (atom nil)) @@ -190,56 +191,77 @@ :default-password password}])) (defn login-section - [{:keys [set-show-profiles]}] - (let [processing (rf/sub [:profile/login-processing]) - {:keys [key-uid name customization-color]} (rf/sub [:profile/login-profile]) - sign-in-enabled? (rf/sub [:sign-in-enabled?]) - profile-picture (rf/sub [:profile/login-profiles-picture key-uid]) - login-multiaccount #(rf/dispatch [:profile.login/login])] - [rn/keyboard-avoiding-view - {:style style/login-container - :keyboardVerticalOffset (- (safe-area/get-bottom))} - [rn/view - {:style style/multi-profile-button-container} - (when config/quo-preview-enabled? + [] + (let [password-value (reagent/atom nil)] + (fn [{:keys [set-show-profiles]}] + (let [{:keys [processing password]} (rf/sub [:profile/login]) + {:keys [key-uid name customization-color]} (rf/sub [:profile/login-profile]) + sign-in-enabled? (rf/sub [:sign-in-enabled?]) + profile-picture (rf/sub [:profile/login-profiles-picture key-uid]) + auth-method (rf/sub [:auth-method]) + login-multiaccount #(rf/dispatch [:profile.login/login]) + on-change-password (fn [value] + (reset! password-value value) + (when (not= value (security/safe-unmask-data password)) + (rf/dispatch [:set-in [:profile/login :password] + (security/mask-data value)]) + (rf/dispatch [:set-in [:profile/login :error] ""])))] + [rn/keyboard-avoiding-view + {:style style/login-container + :keyboardVerticalOffset (- (safe-area/get-bottom))} + [rn/view + {:style style/multi-profile-button-container} + (when config/quo-preview-enabled? + [quo/button + {:size 32 + :type :grey + :background :blur + :icon-only? true + :on-press #(rf/dispatch [:navigate-to :quo-preview]) + :disabled? processing + :accessibility-label :quo-preview + :container-style {:margin-right 12}} + :i/reveal-whitelist]) [quo/button {:size 32 :type :grey :background :blur :icon-only? true - :on-press #(rf/dispatch [:navigate-to :quo-preview]) + :on-press set-show-profiles :disabled? processing - :accessibility-label :quo-preview - :container-style {:margin-right 12}} - :i/reveal-whitelist]) - [quo/button - {:size 32 - :type :grey - :background :blur - :icon-only? true - :on-press set-show-profiles - :disabled? processing - :accessibility-label :show-profiles} - :i/multi-profile]] - [rn/scroll-view - {:keyboard-should-persist-taps :always - :style {:flex 1}} - [quo/profile-card - {:name name - :customization-color (or customization-color :primary) - :profile-picture profile-picture - :card-style style/login-profile-card}] - [password-input]] - [quo/button - {:size 40 - :type :primary - :customization-color (or customization-color :primary) - :accessibility-label :login-button - :icon-left :i/unlocked - :disabled? (or (not sign-in-enabled?) processing) - :on-press login-multiaccount - :container-style {:margin-bottom (+ (safe-area/get-bottom) 12)}} - (i18n/label :t/log-in)]])) + :accessibility-label :show-profiles} + :i/multi-profile]] + [rn/scroll-view + {:keyboard-should-persist-taps :always + :style {:flex 1}} + [quo/profile-card + {:name name + :customization-color (or customization-color :primary) + :profile-picture profile-picture + :card-style style/login-profile-card}] + [standard-authentication/password-input + {:shell? true + :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 + %])}]))) + :password @password-value + :on-change-password on-change-password}]] + [quo/button + {:size 40 + :type :primary + :customization-color (or customization-color :primary) + :accessibility-label :login-button + :icon-left :i/unlocked + :disabled? (or (not sign-in-enabled?) processing) + :on-press login-multiaccount + :container-style {:margin-bottom (+ (safe-area/get-bottom) 12)}} + (i18n/label :t/log-in)]])))) ;; we had to register it here, because of hotreload, overwise on hotreload it will be reseted (defonce show-profiles? (reagent/atom false))