[#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] ## [0.9.28 - Unreleased]
### Added ### Added
### Fixed ### Fixed
Fix app freeze on recover with wrong password
### Changed ### Changed
## [0.9.27] ## [0.9.27]

View File

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

View File

@ -460,6 +460,7 @@
"invalid-number": "Invalid number", "invalid-number": "Invalid number",
"type-a-message": "Type a message...", "type-a-message": "Type a message...",
"recover-password-too-short": "Password is too short", "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", "rinkeby-network": "Rinkeby test network",
"faq": "Frequently asked questions", "faq": "Frequently asked questions",
"currency-display-name-sar": "Saudi Arabia Riyal", "currency-display-name-sar": "Saudi Arabia Riyal",