From fbbee2e268ccf5e0bdf42f8f2d5bf512d3a4960a Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Mon, 19 Sep 2016 14:24:24 +0300 Subject: [PATCH] fixes #237 --- src/status_im/accounts/recover/handlers.cljs | 14 +++++++++----- src/status_im/protocol/listeners.cljs | 11 +++++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/status_im/accounts/recover/handlers.cljs b/src/status_im/accounts/recover/handlers.cljs index 837c140902..457189ed0d 100644 --- a/src/status_im/accounts/recover/handlers.cljs +++ b/src/status_im/accounts/recover/handlers.cljs @@ -4,17 +4,21 @@ [status-im.utils.types :refer [json->clj]] [status-im.utils.identicon :refer [identicon]] [taoensso.timbre :as log] - [clojure.string :as str])) + [clojure.string :as str] + [status-im.protocol.core :as protocol])) (defn account-recovered [result password] (let [_ (log/debug result) data (json->clj result) public-key (:pubkey data) address (:address data) - account {:public-key public-key - :address address - :name address - :photo-path (identicon public-key)}] + {:keys [public private]} (protocol/new-keypair!) + account {:public-key public-key + :address address + :name address + :photo-path (identicon public-key) + :updates-public-key public + :updates-private-key private}] (log/debug "account-recovered") (when (not (str/blank? public-key)) (do diff --git a/src/status_im/protocol/listeners.cljs b/src/status_im/protocol/listeners.cljs index a09b6ddbc9..56afb9b394 100644 --- a/src/status_im/protocol/listeners.cljs +++ b/src/status_im/protocol/listeners.cljs @@ -3,18 +3,25 @@ [status-im.protocol.ack :as ack] [status-im.protocol.web3.utils :as u] [status-im.protocol.encryption :as e] - [taoensso.timbre :refer-macros [debug]])) + [taoensso.timbre :refer-macros [debug] :as log])) (defn- parse-payload [payload] (debug :parse-payload) (r/read-string (u/to-utf8 payload))) +(defn- decrypt [key content] + (try + (r/read-string (e/decrypt key content)) + (catch :default err + (log/warn :decrypt-error err) + nil))) + (defn- parse-content [key {:keys [content]} was-encrypted?] (debug :parse-content "Key exitsts:" (not (nil? key)) "Content exists:" (not (nil? content))) (if (and (not was-encrypted?) key content) - (r/read-string (e/decrypt key content)) + (decrypt key content) content)) (defn message-listener