Skip to content

Commit 8edd260

Browse files
committed
Add steps to password reset
1 parent 74b1916 commit 8edd260

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed

src/status_im/multiaccounts/reset_password/core.cljs

+20-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[status-im.utils.types :as types]
55
[clojure.string :as string]
66
[status-im.utils.security :as security]
7+
[status-im.utils.keychain.core :as keychain]
78
[status-im.popover.core :as popover]
89
[status-im.native-module.core :as status]
910
[status-im.ethereum.core :as ethereum]))
@@ -34,13 +35,19 @@
3435
(fx/defn password-reset-success
3536
{:events [::password-reset-success]}
3637
[{:keys [db] :as cofx}]
37-
(fx/merge cofx
38-
{:db (dissoc
39-
db
40-
:multiaccount/reset-password-form-vals
41-
:multiaccount/reset-password-errors
42-
:multiaccount/reset-password-next-enabled?
43-
:multiaccount/resetting-password?)}))
38+
(let [{:keys [key-uid]} (:multiaccount db)
39+
auth-method (get db :auth-method keychain/auth-method-none)
40+
new-password (get-in db [:multiaccount/reset-password-form-vals :new-password])]
41+
(fx/merge cofx
42+
{:db (dissoc
43+
db
44+
:multiaccount/reset-password-form-vals
45+
:multiaccount/reset-password-errors
46+
:multiaccount/reset-password-next-enabled?
47+
:multiaccount/resetting-password?)}
48+
;; update password in keychain if biometrics are enabled
49+
(when (= auth-method keychain/auth-method-biometric)
50+
(keychain/save-user-password key-uid new-password)))))
4451

4552
(defn change-db-password-cb [res]
4653
(let [{:keys [error]} (types/json->clj res)]
@@ -88,3 +95,9 @@
8895
(assoc form-vals
8996
:address
9097
(get-in db [:multiaccount :wallet-root-address]))})
98+
99+
(comment
100+
(-> re-frame.db/app-db
101+
deref
102+
:auth-method)
103+
)

src/status_im/ui/screens/reset_password/views.cljs

+24-9
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
1212

1313
(defn input-field
14-
([id errors on-submit] (input-field id errors on-submit false))
15-
([id errors on-submit focus?]
14+
[{:keys [id errors on-submit disabled? focus?]
15+
:or {disabled? false focus? false}}]
16+
[react/view {:style {:opacity (if disabled? 0.33 1)}}
1617
[quo/text-input
1718
{:placeholder (i18n/label id)
1819
:default-value ""
1920
:auto-focus focus?
21+
:editable (not disabled?)
2022
:accessibility-label id
2123
:show-cancel false
2224
:style {:margin-bottom 32}
@@ -28,20 +30,33 @@
2830
:error (when-let [error (get errors id)]
2931
(if (keyword? error)
3032
(i18n/label error)
31-
error))}]))
33+
error))}]])
3234

3335
(defview reset-password []
3436
(letsubs [{:keys [form-vals errors next-enabled?]}
3537
[:multiaccount/reset-password-form-vals-and-errors]]
36-
(let [on-submit #(re-frame/dispatch [::reset-password/reset form-vals])]
38+
(let [{:keys [current-password
39+
new-password]} form-vals
40+
on-submit #(re-frame/dispatch [::reset-password/reset form-vals])]
3741
[react/keyboard-avoiding-view {:flex 1}
3842
[react/view {:style {:flex 1
3943
:justify-content :space-between}}
40-
[react/view {:style {:padding-horizontal 16
44+
[react/view {:style {:margin-top 32
45+
:padding-horizontal 16
4146
:padding-vertical 16}}
42-
[input-field :current-password errors on-submit true]
43-
[input-field :new-password errors on-submit]
44-
[input-field :confirm-new-password errors on-submit]]
47+
[input-field {:id :current-password
48+
:errors errors
49+
:on-sumbit on-submit
50+
:disabled? false
51+
:focus? true}]
52+
[input-field {:id :new-password
53+
:errors errors
54+
:on-sumbit on-submit
55+
:disabled? (zero? (count current-password))}]
56+
[input-field {:id :confirm-new-password
57+
:errors errors
58+
:on-sumbit on-submit
59+
:disabled? (zero? (count new-password))}]]
4560
[quo/text {:color :secondary :align :center :size :small
4661
:style {:padding-horizontal 16}}
4762
(i18n/label :t/password-description)]
@@ -85,4 +100,4 @@
85100
[react/view {:align-items :center}
86101
[quo/button {:on-press #(re-frame/dispatch [:hide-popover])
87102
:disabled resetting?}
88-
(i18n/label :t/ok-got-it)]]]))
103+
(i18n/label :t/okay)]]]))

0 commit comments

Comments
 (0)