From 76036c88cc20ef9e8d81ce5f0dcf5ca037328345 Mon Sep 17 00:00:00 2001 From: Dmitry Novotochinov Date: Mon, 10 Sep 2018 16:03:03 +0300 Subject: [PATCH] [#5745] validate accout recover result Signed-off-by: Dmitry Novotochinov --- CHANGELOG.md | 1 + src/status_im/accounts/recover/core.cljs | 20 +++++++++++--------- translations/en.json | 1 + 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46af1a7b9b..d2393d0311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/src/status_im/accounts/recover/core.cljs b/src/status_im/accounts/recover/core.cljs index d15257f5d8..1d9e270387 100644 --- a/src/status_im/accounts/recover/core.cljs +++ b/src/status_im/accounts/recover/core.cljs @@ -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) - :photo-path (identicon/identicon pubkey) - :mnemonic ""}] +(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)] diff --git a/translations/en.json b/translations/en.json index 527caaab16..4e20eca422 100644 --- a/translations/en.json +++ b/translations/en.json @@ -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",