Simplified login event.

This commit is contained in:
Andrey Antukh 2016-05-16 13:27:10 +03:00
parent 6eb65bfe39
commit c8d48d4667
No known key found for this signature in database
GPG Key ID: 4DFEBCB8316A8B95

View File

@ -28,7 +28,8 @@
rs/WatchEvent rs/WatchEvent
(-apply-watch [this state s] (-apply-watch [this state s]
(rx/of (r/navigate :dashboard/projects))) (rx/of (udu/fetch-profile)
(r/navigate :dashboard/projects)))
rs/EffectEvent rs/EffectEvent
(-apply-effect [this state] (-apply-effect [this state]
@ -53,13 +54,12 @@
(-apply-watch [this state s] (-apply-watch [this state s]
(let [params {:username username (let [params {:username username
:password password :password password
:scope "webapp"}] :scope "webapp"}
on-error #(udm/error (tr "errors.auth.unauthorized"))]
(->> (rp/req :fetch/token params) (->> (rp/req :fetch/token params)
(rx/map :payload) (rx/map :payload)
(rx/mapcat #(rx/of (logged-in %) (rx/map logged-in)
(udp/fetch-projects) (rx/catch rp/client-error? on-error)))))
(udu/fetch-profile)))
(rx/catch rp/client-error? #(udm/error (tr "errors.auth.unauthorized")))))))
(defn login (defn login
[params] [params]