Don't fetch profile and projects if authentication is failed.

This commit is contained in:
Andrey Antukh 2016-04-15 23:26:16 +03:00
parent 433d4fe7ee
commit 5ebe483f8a
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -51,19 +51,15 @@
rs/WatchEvent rs/WatchEvent
(-apply-watch [this state s] (-apply-watch [this state s]
(letfn [(on-error [{:keys [status payload]}]
(println status payload)
(uum/error (tr "errors.auth.unauthorized"))
(rx/empty))]
(let [params {:username username (let [params {:username username
:password password :password password
:scope "webapp"}] :scope "webapp"}]
(->> (rp/req :fetch/token params) (->> (rp/req :fetch/token params)
(rx/catch rp/client-error? on-error)
(rx/map :payload) (rx/map :payload)
(rx/mapcat #(rx/of (logged-in %) (rx/mapcat #(rx/of (logged-in %)
(dp/fetch-projects) (udp/fetch-projects)
(udu/fetch-profile)))))))) (udu/fetch-profile)))
(rx/catch rp/client-error? #(udm/error (tr "errors.auth.unauthorized")))))))
(defn login (defn login
[params] [params]