Skip to content

Commit f6121bb

Browse files
committed
authenticate enable biometrics
1 parent bb7377e commit f6121bb

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/status_im2/contexts/onboarding/enable_biometrics/view.cljs

+7-4
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
:theme theme
3131
:blur? true
3232
:on-enter-password (fn [entered-password]
33-
(rf/dispatch [:onboarding-2/enable-biometrics-auth
34-
(security/safe-unmask-data
35-
entered-password)])
33+
(rf/dispatch
34+
[:onboarding-2/authenticate-enable-biometrics
35+
(security/safe-unmask-data
36+
entered-password)])
3637
(rf/dispatch [:hide-bottom-sheet]))
3738
:auth-button-label (i18n/label :t/reveal-sync-code)}))
3839

@@ -45,7 +46,9 @@
4546
[rn/view {:style (style/buttons insets)}
4647
[quo/button
4748
{:accessibility-label :enable-biometrics-button
48-
:on-press #(authenticate-enable-biometric theme)
49+
:on-press #(rf/dispatch (if (= :syncing-results @state/root-id)
50+
(authenticate-enable-biometric theme)
51+
[:onboarding-2/enable-biometrics]))
4952
:icon-left :i/face-id
5053
:customization-color profile-color}
5154
(i18n/label :t/biometric-enable-button {:bio-type-label bio-type-label})]

src/status_im2/contexts/onboarding/events.cljs

+17-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
[status-im2.constants :as constants]
77
[status-im2.contexts.profile.create.events :as profile.create]
88
[status-im2.contexts.profile.recover.events :as profile.recover]
9-
[status-im2.navigation.state :as state]
109
[taoensso.timbre :as log]
1110
[utils.i18n :as i18n]
1211
[utils.re-frame :as rf]
@@ -36,26 +35,30 @@
3635
{:biometric/authenticate {:on-success #(rf/dispatch [:onboarding-2/biometrics-done])
3736
:on-fail #(rf/dispatch [:onboarding-2/biometrics-fail %])}})
3837

39-
(rf/defn enable-biometrics-auth
40-
{:events [:onboarding-2/enable-biometrics-auth]}
38+
(rf/defn authenticate-enable-biometrics
39+
{:events [:onboarding-2/authenticate-enable-biometrics]}
4140
[{:keys [db]} password]
42-
{:db (assoc-in db [:onboarding-2/profile :password] password)
41+
{:db (-> db
42+
(assoc-in [:onboarding-2/profile :password] password)
43+
(assoc-in [:onboarding-2/profile :syncing?] true))
4344
:biometric/authenticate {:on-success #(rf/dispatch [:onboarding-2/biometrics-done])
4445
:on-fail #(rf/dispatch [:onboarding-2/biometrics-fail %])}})
4546

4647
(rf/defn navigate-to-enable-notifications
4748
{:events [:onboarding-2/navigate-to-enable-notifications]}
4849
[{:keys [db]}]
4950
(let [key-uid (get-in db [:profile/profile :key-uid])]
50-
{:dispatch [:navigate-to-within-stack [:enable-notifications :enable-biometrics]]}))
51+
{:db (dissoc db :onboarding-2/profile)
52+
:dispatch [:navigate-to-within-stack [:enable-notifications :enable-biometrics]]}))
5153

5254
(rf/defn biometrics-done
5355
{:events [:onboarding-2/biometrics-done]}
5456
[{:keys [db]}]
55-
{:db (assoc-in db [:onboarding-2/profile :auth-method] constants/auth-method-biometric)
56-
:dispatch (if (= :syncing-results @state/root-id)
57-
[:onboarding-2/finalize-setup]
58-
[:onboarding-2/create-account-and-login])})
57+
(let [syncing? (get-in db [:onboarding-2/profile :syncing?])]
58+
{:db (assoc-in db [:onboarding-2/profile :auth-method] constants/auth-method-biometric)
59+
:dispatch (if syncing?
60+
[:onboarding-2/finalize-setup]
61+
[:onboarding-2/create-account-and-login])}))
5962

6063
(rf/defn biometrics-fail
6164
{:events [:onboarding-2/biometrics-fail]}
@@ -144,16 +147,18 @@
144147
[{:keys [db]}]
145148
(let [masked-password (get-in db [:onboarding-2/profile :password])
146149
key-uid (get-in db [:profile/profile :key-uid])
150+
syncing? (get-in db [:onboarding-2/profile :syncing?])
147151
biometric-enabled? (= (get-in db [:onboarding-2/profile :auth-method])
148152
constants/auth-method-biometric)]
149-
(js/console.log (str "masked password" masked-password))
150153
(cond-> {:db (assoc db :onboarding-2/generated-keys? true)}
151154
biometric-enabled?
152155
(assoc :keychain/save-password-and-auth-method
153156
{:key-uid key-uid
154157
:masked-password masked-password
155-
:on-success #(rf/dispatch [:navigate-to-within-stack
156-
[:enable-notifications :enable-biometrics]])
158+
:on-success (fn []
159+
(if syncing?
160+
(rf/dispatch [:onboarding-2/navigate-to-enable-notifications])
161+
(log/error "successfully saved biometrics")))
157162
:on-error #(log/error "failed to save biometrics"
158163
{:key-uid key-uid
159164
:error %})}))))

0 commit comments

Comments
 (0)