[#15475] (issue 1) Prevent restoring of an existing multiacc
This commit is contained in:
parent
ac2d10bc5d
commit
de86586208
|
@ -5,11 +5,12 @@
|
||||||
[status-im.utils.types :as types]
|
[status-im.utils.types :as types]
|
||||||
[status-im2.config :as config]
|
[status-im2.config :as config]
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
|
[utils.i18n :as i18n]
|
||||||
[utils.security.core :as security]
|
[utils.security.core :as security]
|
||||||
[status-im.native-module.core :as status]
|
[status-im.native-module.core :as status]
|
||||||
[status-im.ethereum.core :as ethereum]
|
[status-im.ethereum.core :as ethereum]
|
||||||
[status-im2.constants :as constants]
|
[status-im2.constants :as constants]
|
||||||
[utils.i18n :as i18n]))
|
[status-im2.contexts.onboarding.profiles.view :as profiles.view]))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:multiaccount/create-account-and-login
|
:multiaccount/create-account-and-login
|
||||||
|
@ -22,10 +23,10 @@
|
||||||
(status/validate-mnemonic
|
(status/validate-mnemonic
|
||||||
(security/safe-unmask-data mnemonic)
|
(security/safe-unmask-data mnemonic)
|
||||||
(fn [result]
|
(fn [result]
|
||||||
(let [{:keys [error]} (types/json->clj result)]
|
(let [{:keys [error keyUID]} (types/json->clj result)]
|
||||||
(if (seq error)
|
(if (seq error)
|
||||||
(when on-error (on-error error))
|
(when on-error (on-error error))
|
||||||
(on-success mnemonic)))))))
|
(on-success mnemonic keyUID)))))))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:multiaccount/restore-account-and-login
|
:multiaccount/restore-account-and-login
|
||||||
|
@ -121,15 +122,28 @@
|
||||||
{:events [:onboarding-2/seed-phrase-entered]}
|
{:events [:onboarding-2/seed-phrase-entered]}
|
||||||
[_ seed-phrase on-error]
|
[_ seed-phrase on-error]
|
||||||
{:multiaccount/validate-mnemonic [seed-phrase
|
{:multiaccount/validate-mnemonic [seed-phrase
|
||||||
#(re-frame/dispatch [:onboarding-2/seed-phrase-validated
|
(fn [mnemonic key-uid]
|
||||||
seed-phrase])
|
(re-frame/dispatch [:onboarding-2/seed-phrase-validated
|
||||||
|
mnemonic key-uid]))
|
||||||
on-error]})
|
on-error]})
|
||||||
|
|
||||||
(rf/defn seed-phrase-validated
|
(rf/defn seed-phrase-validated
|
||||||
{:events [:onboarding-2/seed-phrase-validated]}
|
{:events [:onboarding-2/seed-phrase-validated]}
|
||||||
[{:keys [db]} seed-phrase]
|
[{:keys [db]} seed-phrase key-uid]
|
||||||
|
(if (contains? (:multiaccounts/multiaccounts db) key-uid)
|
||||||
|
{:utils/show-confirmation
|
||||||
|
{:title (i18n/label :t/multiaccount-exists-title)
|
||||||
|
:content (i18n/label :t/multiaccount-exists-content)
|
||||||
|
:confirm-button-text (i18n/label :t/unlock)
|
||||||
|
:on-accept #(do
|
||||||
|
(re-frame/dispatch [:pop-to-root :profiles])
|
||||||
|
;; FIXME(rasom): obviously not cool
|
||||||
|
(reset! profiles.view/show-profiles? false)
|
||||||
|
(re-frame/dispatch
|
||||||
|
[:multiaccounts.login.ui/multiaccount-selected key-uid]))
|
||||||
|
:on-cancel #(re-frame/dispatch [:pop-to-root :multiaccounts])}}
|
||||||
{:db (assoc-in db [:onboarding-2/profile :seed-phrase] seed-phrase)
|
{:db (assoc-in db [:onboarding-2/profile :seed-phrase] seed-phrase)
|
||||||
:dispatch [:navigate-to :create-profile]})
|
:dispatch [:navigate-to :create-profile]}))
|
||||||
|
|
||||||
(rf/defn navigate-to-create-profile
|
(rf/defn navigate-to-create-profile
|
||||||
{:events [:onboarding-2/navigate-to-create-profile]}
|
{:events [:onboarding-2/navigate-to-create-profile]}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "v0.141.1",
|
"version": "v0.141.2",
|
||||||
"commit-sha1": "458f28178ca15732df8e6c806ef5326fad44427c",
|
"commit-sha1": "91c6949cd25449d5459581a21f2c8b929290ced0",
|
||||||
"src-sha256": "1hhfswn17dja62rxkb572afd6fsx86wfxs4j666lhscdz7zzs4gx"
|
"src-sha256": "0d4x1y9jhdxy5jn9kqp5avx157iqz4ma7903c3ys0njmnxhmjyf8"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue