autologin to account when its already created
This commit is contained in:
parent
6fc1e0b46a
commit
7f1ac63cdf
|
@ -4,6 +4,8 @@
|
|||
[status-im.utils.logging :as log]
|
||||
[status-im.components.react :refer [geth]]
|
||||
[status-im.utils.types :refer [json->clj]]
|
||||
[status-im.persistence.simple-kv-store :as kv]
|
||||
[status-im.protocol.state.storage :as storage]
|
||||
[clojure.string :as str]))
|
||||
|
||||
|
||||
|
@ -15,6 +17,9 @@
|
|||
(update db :accounts assoc address account))
|
||||
((after save-account))))
|
||||
|
||||
(defn save-password [password]
|
||||
(storage/put kv/kv-store :password password))
|
||||
|
||||
(defn account-created [result password]
|
||||
(let [data (json->clj result)
|
||||
public-key (:pubkey data)
|
||||
|
@ -24,6 +29,7 @@
|
|||
(log/debug "Created account: " result)
|
||||
(when (not (str/blank? public-key))
|
||||
(do
|
||||
(save-password password)
|
||||
(dispatch [:login-account address password])
|
||||
(dispatch [:initialize-protocol account])
|
||||
(dispatch [:add-account account])))))
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
[status-im.utils.crypt :refer [gen-random-bytes]]
|
||||
[status-im.components.react :refer [geth]]
|
||||
[status-im.utils.handlers :refer [register-handler] :as u]
|
||||
[status-im.models.protocol :as protocol]
|
||||
status-im.chat.handlers
|
||||
status-im.chat.handlers.animation
|
||||
status-im.group-settings.handlers
|
||||
|
@ -57,7 +58,9 @@
|
|||
(register-handler :initialize-db
|
||||
(fn [_ _]
|
||||
(assoc app-db
|
||||
:signed-up (storage/get kv/kv-store :signed-up))))
|
||||
:signed-up (storage/get kv/kv-store :signed-up)
|
||||
:user-identity (protocol/stored-identity nil)
|
||||
:password (storage/get kv/kv-store :password))))
|
||||
|
||||
(register-handler :initialize-crypt
|
||||
(u/side-effect!
|
||||
|
@ -74,11 +77,20 @@
|
|||
(.toBits (.. js/ecc -sjcl -codec -hex))
|
||||
(.addEntropy (.. js/ecc -sjcl -random)))
|
||||
(dispatch [:crypt-initialized]))))))))
|
||||
|
||||
(defn node-started [db result]
|
||||
(let [identity (:user-identity db)
|
||||
password (:password db)]
|
||||
(log/debug "Started Node: " result)
|
||||
(when identity (do
|
||||
(dispatch [:login-account (:address identity) password])
|
||||
(dispatch [:initialize-protocol identity])))))
|
||||
|
||||
(register-handler :initialize-geth
|
||||
(u/side-effect!
|
||||
(fn [_ _]
|
||||
(fn [db _]
|
||||
(log/debug "Starting node")
|
||||
(.startNode geth (fn [result] (log/debug "Started Node: " result))))))
|
||||
(.startNode geth (fn [result] (node-started db result))))))
|
||||
|
||||
(register-handler :crypt-initialized
|
||||
(u/side-effect!
|
||||
|
|
Loading…
Reference in New Issue