Merge branch 'master' of bitbucket.org:brycecovertoperations/integreat

This commit is contained in:
Bryce Covert
2019-03-01 08:35:44 -08:00
5 changed files with 31 additions and 15 deletions

View File

@@ -43,5 +43,6 @@ services:
- DATOMIC_SQL_HOST=database
ports:
- 4334:4334
restart: on-failure

View File

@@ -46,7 +46,7 @@
(if (and token user)
{:status 301
:headers {"Location" (str "/?jwt=" (jwt/sign (doto {:user (:name profile)
:exp (time/plus (time/now) (time/days 7))
:exp (time/plus (time/now) (time/days 30))
:user/clients (map (fn [c]
(dissoc c :client/bank-accounts ))
(:user/clients user))

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

View File

@@ -164,9 +164,10 @@
(re-frame/reg-event-fx
::logout
(fn [{:keys [db]} [_]]
(fn [{:keys [db]} [_ logout-reason]]
{:db (assoc db :user nil :menu {:client {:active? false}
:account {:active? false}})
:account {:active? false}}
:logout-reason logout-reason)
:redirect (bidi/path-for routes/routes :login)
:set-local-storage ["jwt" nil]}))

View File

@@ -9,12 +9,18 @@
[auto-ap.routes :as routes]
[bidi.bidi :as bidi]))
(re-frame/reg-sub
::logout-reason
(fn [db] (-> db :logout-reason)))
(defn login-page []
[:div.container
[:section.is-fullheight.hero
[:div.hero-body
[:div.container
[:div.column.is-4.is-offset-4.has-text-centered
(when-let [reason @(re-frame/subscribe [::logout-reason])]
[:div.notification.is-warning reason])
[:h1.title "Login"]
[:div.box.slideInFromBelow