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]}] (let [params {:username username
(println status payload) :password password
(uum/error (tr "errors.auth.unauthorized")) :scope "webapp"}]
(rx/empty))] (->> (rp/req :fetch/token params)
(let [params {:username username (rx/map :payload)
:password password (rx/mapcat #(rx/of (logged-in %)
:scope "webapp"}] (udp/fetch-projects)
(->> (rp/req :fetch/token params) (udu/fetch-profile)))
(rx/catch rp/client-error? on-error) (rx/catch rp/client-error? #(udm/error (tr "errors.auth.unauthorized")))))))
(rx/map :payload)
(rx/mapcat #(rx/of (logged-in %)
(dp/fetch-projects)
(udu/fetch-profile))))))))
(defn login (defn login
[params] [params]