Kicks the user out when their session expires.

This commit is contained in:
BC
2019-03-01 07:58:30 -08:00
parent 1fa6154f39
commit c726613ecc
5 changed files with 31 additions and 15 deletions

View File

@@ -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)))))))