Merge pull request #239 from status-im/bug/#237
Fix error after account recovery
Former-commit-id: c06b1249e8
This commit is contained in:
commit
9f99dba7bd
|
@ -4,17 +4,21 @@
|
||||||
[status-im.utils.types :refer [json->clj]]
|
[status-im.utils.types :refer [json->clj]]
|
||||||
[status-im.utils.identicon :refer [identicon]]
|
[status-im.utils.identicon :refer [identicon]]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[clojure.string :as str]))
|
[clojure.string :as str]
|
||||||
|
[status-im.protocol.core :as protocol]))
|
||||||
|
|
||||||
(defn account-recovered [result password]
|
(defn account-recovered [result password]
|
||||||
(let [_ (log/debug result)
|
(let [_ (log/debug result)
|
||||||
data (json->clj result)
|
data (json->clj result)
|
||||||
public-key (:pubkey data)
|
public-key (:pubkey data)
|
||||||
address (:address data)
|
address (:address data)
|
||||||
account {:public-key public-key
|
{:keys [public private]} (protocol/new-keypair!)
|
||||||
:address address
|
account {:public-key public-key
|
||||||
:name address
|
:address address
|
||||||
:photo-path (identicon public-key)}]
|
:name address
|
||||||
|
:photo-path (identicon public-key)
|
||||||
|
:updates-public-key public
|
||||||
|
:updates-private-key private}]
|
||||||
(log/debug "account-recovered")
|
(log/debug "account-recovered")
|
||||||
(when (not (str/blank? public-key))
|
(when (not (str/blank? public-key))
|
||||||
(do
|
(do
|
||||||
|
|
|
@ -3,18 +3,25 @@
|
||||||
[status-im.protocol.ack :as ack]
|
[status-im.protocol.ack :as ack]
|
||||||
[status-im.protocol.web3.utils :as u]
|
[status-im.protocol.web3.utils :as u]
|
||||||
[status-im.protocol.encryption :as e]
|
[status-im.protocol.encryption :as e]
|
||||||
[taoensso.timbre :refer-macros [debug]]))
|
[taoensso.timbre :refer-macros [debug] :as log]))
|
||||||
|
|
||||||
(defn- parse-payload [payload]
|
(defn- parse-payload [payload]
|
||||||
(debug :parse-payload)
|
(debug :parse-payload)
|
||||||
(r/read-string (u/to-utf8 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?]
|
(defn- parse-content [key {:keys [content]} was-encrypted?]
|
||||||
(debug :parse-content
|
(debug :parse-content
|
||||||
"Key exitsts:" (not (nil? key))
|
"Key exitsts:" (not (nil? key))
|
||||||
"Content exists:" (not (nil? content)))
|
"Content exists:" (not (nil? content)))
|
||||||
(if (and (not was-encrypted?) key content)
|
(if (and (not was-encrypted?) key content)
|
||||||
(r/read-string (e/decrypt key content))
|
(decrypt key content)
|
||||||
content))
|
content))
|
||||||
|
|
||||||
(defn message-listener
|
(defn message-listener
|
||||||
|
|
Loading…
Reference in New Issue