Send international phone number to server. Send confirmation code.

This commit is contained in:
virvar 2016-05-18 16:45:03 +03:00
parent 981912cd2c
commit 9274ba0ebb
2 changed files with 17 additions and 11 deletions

View File

@ -12,6 +12,8 @@
[syng-im.models.chats :as chats] [syng-im.models.chats :as chats]
[syng-im.navigation.handlers :as nav] [syng-im.navigation.handlers :as nav]
[syng-im.models.chats :as c] [syng-im.models.chats :as c]
[syng-im.handlers.server :as server]
[syng-im.utils.phone-number :refer [format-phone-number]]
[syng-im.utils.handlers :as u])) [syng-im.utils.handlers :as u]))
(register-handler :set-show-actions (register-handler :set-show-actions
@ -222,15 +224,17 @@
(assoc db :password-saved true))) (assoc db :password-saved true)))
(register-handler :sign-up (register-handler :sign-up
(-> (fn [db [_ phone-number]] (fn [db [_ phone-number]]
;; todo save phone number to db ;; todo save phone number to db
(assoc db :user-phone-number phone-number)) (let [formatted (format-phone-number phone-number)]
((after (fn [& _] (sign-up-service/on-sign-up-response)))))) (-> db
(assoc :user-phone-number formatted)
(server/sign-up formatted sign-up-service/on-sign-up-response)))))
(register-handler :sign-up-confirm (register-handler :sign-up-confirm
(fn [db [_ confirmation-code]] (fn [db [_ confirmation-code]]
(sign-up-service/on-send-code-response confirmation-code) (server/sign-up-confirm confirmation-code sign-up-service/on-send-code-response)
(sign-up-service/set-signed-up db true))) db))
(register-handler :set-signed-up (register-handler :set-signed-up
(fn [db [_ signed-up]] (fn [db [_ signed-up]]

View File

@ -37,19 +37,21 @@
(dispatch [:set-signed-up true])) (dispatch [:set-signed-up true]))
(defn sync-contacts [] (defn sync-contacts []
;; TODO 'on-sync-contacts' is never called
(dispatch [:sync-contacts on-sync-contacts])) (dispatch [:sync-contacts on-sync-contacts]))
(defn on-send-code-response [body] (defn on-send-code-response [body]
(dispatch [:received-msg (dispatch [:received-msg
{:msg-id (random/id) {:msg-id (random/id)
;; todo replace by real check :content (:message body)
:content (if (= "1111" body)
"Confirmed"
"Wrong code")
:content-type text-content-type :content-type text-content-type
:outgoing false :outgoing false
:from "console" :from "console"
:to "me"}])) :to "me"}])
(when (:confirmed body)
(sync-contacts)
;; TODO should be called after sync-contacts?
(dispatch [:set-signed-up true])))
; todo fn name is not too smart, but... ; todo fn name is not too smart, but...
(defn command-content (defn command-content