fix signup process

Former-commit-id: 763aac2141
This commit is contained in:
Adrian Tiberius 2016-06-30 19:05:28 +03:00
parent ea7c5b1665
commit b8a0269357
6 changed files with 25 additions and 23 deletions

View File

@ -10,7 +10,7 @@
[prismatic/schema "1.0.4"]
^{:voom {:repo "git@github.com:status-im/status-lib.git"
:branch "master"}}
[status-im/protocol "0.1.1-20160630_104454-gd663db0"]
[status-im/protocol "0.1.1-20160630_153846-gbf92f5f"]
[natal-shell "0.1.6"]
[com.andrewmcveigh/cljs-time "0.4.0"]]
:plugins [[lein-cljsbuild "1.1.1"]

View File

@ -18,13 +18,14 @@
(defn account-created [result]
(let [data (json->clj result)
public-key (:pubkey data)
address (:address data)]
address (:address data)
account {:public-key public-key
:address address}]
(log/debug "Created account: " result)
(when (not (str/blank? public-key))
(do
(dispatch [:initialize-protocol public-key])
(dispatch [:add-account {:address address
:public-key public-key}])))))
(dispatch [:initialize-protocol account])
(dispatch [:add-account account])))))
(register-handler :create-account
(-> (fn [db [_ password]]

View File

@ -1,17 +1,20 @@
(ns status-im.handlers.server
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[status-im.utils.utils :refer [log on-error http-post]]
[status-im.utils.utils :refer [on-error http-post]]
[status-im.utils.logging :as log]))
(defn sign-up
[db phone-number handler]
;(user-data/save-phone-number phone-number)
(http-post "sign-up" {:phone-number phone-number
:whisper-identity (get-in db [:user-identity :public])}
(fn [body]
(log body)
(handler)))
db)
(let [{:keys [public-key address] :as account} (get-in db [:user-identity])]
;(user-data/save-phone-number phone-number)
(log/debug "signing up with public-key" public-key "and phone " phone-number)
(http-post "sign-up" {:phone-number phone-number
:whisper-identity public-key
:address address}
(fn [body]
(log/debug body)
(handler)))
db))
(defn sign-up-confirm
[confirmation-code handler]

View File

@ -12,13 +12,11 @@
(assoc-in db db/protocol-initialized-path initialized?))
(defn update-identity [db identity]
(let [password (:identity-password db)
encrypted (password-encrypt password (to-edn-string identity))]
(s/put kv/kv-store :identity encrypted)
(let [identity-string (to-edn-string identity)]
(s/put kv/kv-store :identity identity-string)
(assoc db :user-identity identity)))
(defn stored-identity [db]
(let [encrypted (s/get kv/kv-store :identity)
password (:identity-password db)]
(when encrypted
(read-string (password-decrypt password encrypted)))))
(let [identity (s/get kv/kv-store :identity)]
(when identity
(read-string identity))))

View File

@ -67,7 +67,7 @@
phone-number [:get :phone-number]
email [:get :email]
status [:get :status]
identity [:get-in [:user-identity :public]]]
identity [:get-in [:user-identity :public-key]]]
[scroll-view {:style st/profile}
[touchable-highlight {:style st/back-btn-touchable
:on-press #(dispatch [:navigate-back])}

View File

@ -17,8 +17,8 @@
(register-handler :initialize-protocol
(u/side-effect!
(fn [db [_ public-key]]
(init-protocol public-key (make-handler db)))))
(fn [db [_ account]]
(init-protocol account (make-handler db)))))
(register-handler :protocol-initialized
(fn [db [_ identity]]