autologin to account when its already created
Former-commit-id: 7f1ac63cdf
This commit is contained in:
parent
b69d17ff70
commit
7a0941368f
|
@ -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])))))
|
||||
|
@ -34,6 +40,6 @@
|
|||
db)))
|
||||
|
||||
(register-handler :login-account
|
||||
(-> (fn [db [_ address password]]
|
||||
(.login geth address password (fn [result] (log/debug "Logged in account: " address result)))
|
||||
db)))
|
||||
(-> (fn [db [_ address password]]
|
||||
(.login geth address password (fn [result] (log/debug "Logged in account: " address result)))
|
||||
db)))
|
|
@ -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 [_ _]
|
||||
(log/debug "Starting node")
|
||||
(.startNode geth (fn [result] (log/debug "Started Node: " result))))))
|
||||
(u/side-effect!
|
||||
(fn [db _]
|
||||
(log/debug "Starting node")
|
||||
(.startNode geth (fn [result] (node-started db result))))))
|
||||
|
||||
(register-handler :crypt-initialized
|
||||
(u/side-effect!
|
||||
|
|
Loading…
Reference in New Issue