[#5745] validate accout recover result

Signed-off-by: Dmitry Novotochinov <dmitry.novot@gmail.com>
This commit is contained in:
Dmitry Novotochinov 2018-09-10 16:03:03 +03:00
parent 94ee56e43a
commit 76036c88cc
No known key found for this signature in database
GPG Key ID: 43D1DAF5AD39C927
3 changed files with 13 additions and 9 deletions

View File

@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [0.9.28 - Unreleased]
### Added
### Fixed
Fix app freeze on recover with wrong password
### Changed
## [0.9.27]

View File

@ -58,18 +58,20 @@
(let [password (get-in db [:accounts/recover :password])]
{:db (assoc-in db [:accounts/recover :password-error] (check-password-errors password))}))
(defn on-account-recovered [result password cofx]
(let [db (:db cofx)
data (types/json->clj result)
pubkey (:pubkey data)
account {:pubkey pubkey
:address (:address data)
(defn validate-recover-result [{:keys [error pubkey address]} password {:keys [db] :as cofx}]
(if (empty? error)
(let [account {:pubkey pubkey
:address address
:photo-path (identicon/identicon pubkey)
:mnemonic ""}]
(accounts.create/on-account-created account password true cofx))
{:db (assoc-in db [:accounts/recover :password-error] :recover-password-invalid)}))
(defn on-account-recovered [result password {:keys [db] :as cofx}]
(let [data (types/json->clj result)]
(handlers-macro/merge-fx cofx
{:db (assoc-in db [:accounts/recover :processing?] false)}
(accounts.create/on-account-created account password true))))
(validate-recover-result data password))))
(defn recover-account [{:keys [db]}]
(let [{:keys [password passphrase]} (:accounts/recover db)]

View File

@ -460,6 +460,7 @@
"invalid-number": "Invalid number",
"type-a-message": "Type a message...",
"recover-password-too-short": "Password is too short",
"recover-password-invalid": "This account already exists but passwords do not match",
"rinkeby-network": "Rinkeby test network",
"faq": "Frequently asked questions",
"currency-display-name-sar": "Saudi Arabia Riyal",