mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-05 13:25:43 +00:00
[#7189] Proper handle of restoring existing account with wrong password
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
15747558fa
commit
de5463532b
@ -71,15 +71,21 @@
|
|||||||
:address address
|
:address address
|
||||||
:photo-path (identicon/identicon pubkey)
|
:photo-path (identicon/identicon pubkey)
|
||||||
:mnemonic ""}]
|
:mnemonic ""}]
|
||||||
(accounts.create/on-account-created cofx account password {:seed-backed-up? true}))
|
(accounts.create/on-account-created
|
||||||
{:db (assoc-in db [:accounts/recover :password-error] :recover-password-invalid)}))
|
cofx account password {:seed-backed-up? true}))
|
||||||
|
{:db (-> db
|
||||||
|
(update :accounts/recover assoc
|
||||||
|
:processing? false
|
||||||
|
:password ""
|
||||||
|
:password-error :recover-password-invalid)
|
||||||
|
(update :accounts/recover dissoc
|
||||||
|
:password-valid?))
|
||||||
|
:node/stop nil}))
|
||||||
|
|
||||||
(fx/defn on-account-recovered
|
(fx/defn on-account-recovered
|
||||||
[{:keys [db] :as cofx} result password]
|
[cofx result password]
|
||||||
(let [data (types/json->clj result)]
|
(let [data (types/json->clj result)]
|
||||||
(fx/merge cofx
|
(validate-recover-result cofx data password)))
|
||||||
{:db (dissoc db :accounts/recover)}
|
|
||||||
(validate-recover-result data password))))
|
|
||||||
|
|
||||||
(fx/defn recover-account
|
(fx/defn recover-account
|
||||||
[{:keys [db random-guid-generator] :as cofx}]
|
[{:keys [db random-guid-generator] :as cofx}]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
(ns status-im.ui.screens.accounts.recover.views
|
(ns status-im.ui.screens.accounts.recover.views
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
(:require-macros [status-im.utils.views :refer [defview letsubs]
|
||||||
|
:as views])
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[status-im.ui.components.text-input.view :as text-input]
|
[status-im.ui.components.text-input.view :as text-input]
|
||||||
@ -14,7 +15,8 @@
|
|||||||
[status-im.react-native.js-dependencies :as js-dependencies]
|
[status-im.react-native.js-dependencies :as js-dependencies]
|
||||||
[status-im.ui.components.common.common :as components.common]
|
[status-im.ui.components.common.common :as components.common]
|
||||||
[status-im.utils.security :as security]
|
[status-im.utils.security :as security]
|
||||||
[status-im.utils.platform :as platform]))
|
[status-im.utils.platform :as platform]
|
||||||
|
[clojure.string :as string]))
|
||||||
|
|
||||||
(defview passphrase-input [passphrase error warning]
|
(defview passphrase-input [passphrase error warning]
|
||||||
(letsubs [input-ref (reagent/atom nil)]
|
(letsubs [input-ref (reagent/atom nil)]
|
||||||
@ -34,6 +36,13 @@
|
|||||||
warning (i18n/label warning))}]))
|
warning (i18n/label warning))}]))
|
||||||
|
|
||||||
(defview password-input [password error on-submit-editing]
|
(defview password-input [password error on-submit-editing]
|
||||||
|
(views/letsubs [inp-ref (atom nil)]
|
||||||
|
{:component-will-update
|
||||||
|
(fn [_ [_ new-password]]
|
||||||
|
(when (and (string? new-password)
|
||||||
|
(string/blank? new-password)
|
||||||
|
@inp-ref)
|
||||||
|
(.clear @inp-ref)))}
|
||||||
[react/view {:style styles/password-input
|
[react/view {:style styles/password-input
|
||||||
:important-for-accessibility :no-hide-descendants}
|
:important-for-accessibility :no-hide-descendants}
|
||||||
[text-input/text-input-with-label
|
[text-input/text-input-with-label
|
||||||
@ -46,14 +55,21 @@
|
|||||||
:on-blur #(re-frame/dispatch [:accounts.recover.ui/password-input-blured])
|
:on-blur #(re-frame/dispatch [:accounts.recover.ui/password-input-blured])
|
||||||
:secure-text-entry true
|
:secure-text-entry true
|
||||||
:error (when error (i18n/label error))
|
:error (when error (i18n/label error))
|
||||||
:on-submit-editing on-submit-editing}]])
|
:on-submit-editing on-submit-editing
|
||||||
|
:ref #(reset! inp-ref %)}]]))
|
||||||
|
|
||||||
(defview recover []
|
(defview recover []
|
||||||
(letsubs [recovered-account [:get-recover-account]]
|
(letsubs [recovered-account [:get-recover-account]
|
||||||
(let [{:keys [passphrase password processing passphrase-valid? password-valid?
|
node-status? [:get :node/status]]
|
||||||
|
(let [{:keys [passphrase password passphrase-valid? password-valid?
|
||||||
password-error passphrase-error passphrase-warning processing?]} recovered-account
|
password-error passphrase-error passphrase-warning processing?]} recovered-account
|
||||||
|
node-stopped? (or (nil? node-status?)
|
||||||
|
(= :stopped node-status?))
|
||||||
valid-form? (and password-valid? passphrase-valid?)
|
valid-form? (and password-valid? passphrase-valid?)
|
||||||
disabled? (or (not recovered-account) processing? (not valid-form?))
|
disabled? (or (not recovered-account)
|
||||||
|
processing?
|
||||||
|
(not valid-form?)
|
||||||
|
(not node-stopped?))
|
||||||
sign-in #(re-frame/dispatch [:accounts.recover.ui/sign-in-button-pressed])]
|
sign-in #(re-frame/dispatch [:accounts.recover.ui/sign-in-button-pressed])]
|
||||||
[react/keyboard-avoiding-view {:style styles/screen-container}
|
[react/keyboard-avoiding-view {:style styles/screen-container}
|
||||||
[status-bar/status-bar]
|
[status-bar/status-bar]
|
||||||
@ -67,7 +83,7 @@
|
|||||||
[react/i18n-text {:style styles/recover-release-warning
|
[react/i18n-text {:style styles/recover-release-warning
|
||||||
:key :recover-account-warning}])]
|
:key :recover-account-warning}])]
|
||||||
[react/view components.styles/flex]
|
[react/view components.styles/flex]
|
||||||
(if processing
|
(if processing?
|
||||||
[react/view styles/processing-view
|
[react/view styles/processing-view
|
||||||
[react/activity-indicator {:animating true}]
|
[react/activity-indicator {:animating true}]
|
||||||
[react/i18n-text {:style styles/sign-you-in
|
[react/i18n-text {:style styles/sign-you-in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user