Kicks the user out when their session expires.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
[clojure.walk :as walk]
|
||||
[venia.core :as v]
|
||||
[auto-ap.history :as p]
|
||||
[auto-ap.events :as events]
|
||||
[pushy.core :as pushy]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
@@ -155,18 +156,25 @@
|
||||
:body (when = (:post method) query)
|
||||
:url (str "/api/graphql?query=" (when (= :get method) (js/encodeURIComponent query))
|
||||
"&variables=" (pr-str (or variables {})))}))]
|
||||
(if (>= (:status response) 400)
|
||||
(cond
|
||||
(= (:status response) 401)
|
||||
(re-frame/dispatch [::events/logout "Your session has expired. Please log in again."])
|
||||
|
||||
|
||||
|
||||
(>= (:status response) 400)
|
||||
(when on-error
|
||||
(->> response
|
||||
:body
|
||||
:errors
|
||||
(dates->date-times)
|
||||
(map #(assoc % :status (:status response)))
|
||||
(conj on-error)
|
||||
(re-frame/dispatch)))
|
||||
:body
|
||||
:errors
|
||||
(dates->date-times)
|
||||
(map #(assoc % :status (:status response)))
|
||||
(conj on-error)
|
||||
(re-frame/dispatch)))
|
||||
:else
|
||||
(->> response
|
||||
:body
|
||||
:data
|
||||
(dates->date-times)
|
||||
(conj on-success)
|
||||
(re-frame/dispatch)))))))
|
||||
:body
|
||||
:data
|
||||
(dates->date-times)
|
||||
(conj on-success)
|
||||
(re-frame/dispatch)))))))
|
||||
|
||||
Reference in New Issue
Block a user