mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-28 01:16:50 +00:00
Send phone-number to server
Former-commit-id: f592babca828d2742295fafaf4a476597ed2c82c
This commit is contained in:
parent
756b682d68
commit
872dd9a56d
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
(def ethereum-rpc-url "http://localhost:8545")
|
(def ethereum-rpc-url "http://localhost:8545")
|
||||||
|
|
||||||
(def server-address "http://rpc0.syng.im:20000/")
|
;; (def server-address "http://rpc0.syng.im:20000/")
|
||||||
;; (def server-address "http://10.0.3.2:3000/")
|
(def server-address "http://10.0.3.2:3000/")
|
||||||
|
|
||||||
(def text-content-type "text/plain")
|
(def text-content-type "text/plain")
|
||||||
(def content-type-command "command")
|
(def content-type-command "command")
|
||||||
|
@ -190,9 +190,8 @@
|
|||||||
;; -- Sign up --------------------------------------------------------------
|
;; -- Sign up --------------------------------------------------------------
|
||||||
|
|
||||||
(register-handler :sign-up
|
(register-handler :sign-up
|
||||||
(fn [db [_ phone-number whisper-identity handler]]
|
(fn [db [_ phone-number handler]]
|
||||||
(server/sign-up phone-number whisper-identity handler)
|
(server/sign-up db phone-number handler)))
|
||||||
db))
|
|
||||||
|
|
||||||
(register-handler :set-confirmation-code
|
(register-handler :set-confirmation-code
|
||||||
(fn [db [_ value]]
|
(fn [db [_ value]]
|
||||||
|
@ -5,13 +5,14 @@
|
|||||||
[syng-im.utils.logging :as log]))
|
[syng-im.utils.logging :as log]))
|
||||||
|
|
||||||
(defn sign-up
|
(defn sign-up
|
||||||
[phone-number whisper-identity handler]
|
[db phone-number handler]
|
||||||
(user-data/save-phone-number phone-number)
|
(user-data/save-phone-number phone-number)
|
||||||
(http-post "sign-up" {:phone-number phone-number
|
(http-post "sign-up" {:phone-number phone-number
|
||||||
:whisper-identity (:public whisper-identity)}
|
:whisper-identity (get-in db [:user-identity :public])}
|
||||||
(fn [body]
|
(fn [body]
|
||||||
(log body)
|
(log body)
|
||||||
(handler))))
|
(handler)))
|
||||||
|
db)
|
||||||
|
|
||||||
(defn sign-up-confirm
|
(defn sign-up-confirm
|
||||||
[confirmation-code handler]
|
[confirmation-code handler]
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
[syng-im.utils.utils :refer [log on-error http-post toast]]
|
[syng-im.utils.utils :refer [log on-error http-post toast]]
|
||||||
[syng-im.utils.logging :as log]
|
[syng-im.utils.logging :as log]
|
||||||
[syng-im.utils.random :as random]
|
[syng-im.utils.random :as random]
|
||||||
|
[syng-im.utils.phone-number :refer [format-phone-number]]
|
||||||
[syng-im.constants :refer [text-content-type
|
[syng-im.constants :refer [text-content-type
|
||||||
content-type-command
|
content-type-command
|
||||||
content-type-command-request]]))
|
content-type-command-request]]))
|
||||||
@ -35,7 +36,7 @@
|
|||||||
:outgoing false
|
:outgoing false
|
||||||
:from "console"
|
:from "console"
|
||||||
:to "me"}])
|
:to "me"}])
|
||||||
(dispatch [:set-chat-command :keypair-password])
|
;; (dispatch [:set-chat-command :keypair-password])
|
||||||
db)
|
db)
|
||||||
|
|
||||||
(defn send-console-msg [text]
|
(defn send-console-msg [text]
|
||||||
@ -46,6 +47,47 @@
|
|||||||
:content-type text-content-type
|
:content-type text-content-type
|
||||||
:outgoing true})
|
:outgoing true})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;; ----------
|
||||||
|
;; server
|
||||||
|
;; from confirm code view
|
||||||
|
(comment
|
||||||
|
(defn sync-contacts [navigator]
|
||||||
|
(dispatch [:sync-contacts #(show-home-view navigator)]))
|
||||||
|
|
||||||
|
(defn on-send-code-response [navigator body]
|
||||||
|
(log body)
|
||||||
|
(toast (if (:confirmed body)
|
||||||
|
"Confirmed"
|
||||||
|
"Wrong code"))
|
||||||
|
(if (:confirmed body)
|
||||||
|
;; TODO user action required
|
||||||
|
(sync-contacts navigator)
|
||||||
|
(dispatch [:set-loading false])))
|
||||||
|
|
||||||
|
(defn code-valid? [code]
|
||||||
|
(= 4 (count code)))
|
||||||
|
|
||||||
|
(defn send-code [code navigator]
|
||||||
|
(when (code-valid? code)
|
||||||
|
(dispatch [:set-loading true])
|
||||||
|
(dispatch [:sign-up-confirm code (partial on-send-code-response navigator)])))
|
||||||
|
|
||||||
|
(defn update-code [value]
|
||||||
|
(let [formatted value]
|
||||||
|
(dispatch [:set-confirmation-code formatted]))))
|
||||||
|
|
||||||
|
;; from sign up view
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;; ----------
|
||||||
|
;; end server
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn- handle-password [content]
|
(defn- handle-password [content]
|
||||||
;; TODO validate and save password
|
;; TODO validate and save password
|
||||||
(dispatch [:received-msg
|
(dispatch [:received-msg
|
||||||
@ -102,9 +144,7 @@
|
|||||||
:from "console"
|
:from "console"
|
||||||
:to "me"}]))
|
:to "me"}]))
|
||||||
|
|
||||||
(defn- handle-phone [content]
|
(defn on-sign-up-response []
|
||||||
;; TODO validate and save phone number
|
|
||||||
;; send phone to server
|
|
||||||
(dispatch [:received-msg
|
(dispatch [:received-msg
|
||||||
{:msg-id "10"
|
{:msg-id "10"
|
||||||
:content (commands/format-command-request-msg-content
|
:content (commands/format-command-request-msg-content
|
||||||
@ -116,6 +156,10 @@
|
|||||||
:from "console"
|
:from "console"
|
||||||
:to "me"}]))
|
:to "me"}]))
|
||||||
|
|
||||||
|
(defn- handle-phone [content]
|
||||||
|
(let [phone-number (format-phone-number content)]
|
||||||
|
(dispatch [:sign-up phone-number on-sign-up-response])))
|
||||||
|
|
||||||
(defn- handle-confirmation-code [content]
|
(defn- handle-confirmation-code [content]
|
||||||
;; TODO validate confirmation code
|
;; TODO validate confirmation code
|
||||||
;; send code to server
|
;; send code to server
|
||||||
|
@ -65,11 +65,11 @@
|
|||||||
|
|
||||||
;; -- User data --------------------------------------------------------------
|
;; -- User data --------------------------------------------------------------
|
||||||
|
|
||||||
(register-sub
|
;; (register-sub
|
||||||
:get-user-phone-number
|
;; :get-user-phone-number
|
||||||
(fn [db _]
|
;; (fn [db _]
|
||||||
(reaction
|
;; (reaction
|
||||||
(get @db :user-phone-number))))
|
;; (get @db :user-phone-number))))
|
||||||
|
|
||||||
(register-sub
|
(register-sub
|
||||||
:get-user-identity
|
:get-user-identity
|
||||||
|
Loading…
x
Reference in New Issue
Block a user