Send international phone number to server. Send confirmation code.

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

View File

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

View File

@ -37,19 +37,21 @@
(dispatch [:set-signed-up true]))
(defn sync-contacts []
;; TODO 'on-sync-contacts' is never called
(dispatch [:sync-contacts on-sync-contacts]))
(defn on-send-code-response [body]
(dispatch [:received-msg
{:msg-id (random/id)
;; todo replace by real check
:content (if (= "1111" body)
"Confirmed"
"Wrong code")
:content (:message body)
:content-type text-content-type
:outgoing false
: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...
(defn command-content