More reliability with company dropdown
This commit is contained in:
@@ -325,7 +325,7 @@
|
|||||||
(wrap-session {:store (cookie-store
|
(wrap-session {:store (cookie-store
|
||||||
{:key
|
{:key
|
||||||
(byte-array
|
(byte-array
|
||||||
[42, 52, -31, 105, -126, -33, -118, -69, -82, -59, -15, -69, -38, 103, -102, -1])})})
|
[42, 52, -31, 101, -126, -33, -118, -69, -82, -59, -15, -69, -38, 103, -102, -1])})})
|
||||||
|
|
||||||
#_(wrap-reload)
|
#_(wrap-reload)
|
||||||
(wrap-params)
|
(wrap-params)
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
(ns auto-ap.session-version
|
(ns auto-ap.session-version
|
||||||
(:require [bidi.bidi :as bidi]))
|
(:require [bidi.bidi :as bidi]
|
||||||
|
[auto-ap.logging :as alog]))
|
||||||
|
|
||||||
;; TODO this should only be done until SSR is complete
|
;; TODO this should only be done until SSR is complete
|
||||||
;; once it is, it should just use redirects based on headers
|
;; once it is, it should just use redirects based on headers
|
||||||
;; no header=use default, mismatch header=redirect to login
|
;; no header=use default, mismatch header=redirect to login
|
||||||
(def current-session-version 1)
|
(def current-session-version 2)
|
||||||
(defn wrap-session-version
|
(defn wrap-session-version
|
||||||
[handler]
|
[handler]
|
||||||
(fn [request]
|
(fn [request]
|
||||||
@@ -13,28 +14,9 @@
|
|||||||
(:uri request)
|
(:uri request)
|
||||||
:request-method (:request-method request))
|
:request-method (:request-method request))
|
||||||
is-normal-route? (or (keyword? route)
|
is-normal-route? (or (keyword? route)
|
||||||
(keyword? (:handler route)))
|
(keyword? (:handler route)))] ;; TODO SSR icky
|
||||||
whitelist #{:fastlink :oauth :login :health :raw-query :results-csv-query :results-json-query
|
(if (and (not= (:version session current-session-version) current-session-version)
|
||||||
:export-expected-deposits
|
|
||||||
:export-trial-balance
|
|
||||||
:export-sales
|
|
||||||
:export-transactions
|
|
||||||
:export-company-vendors
|
|
||||||
:export-payments
|
|
||||||
:export-ntg-sales-snapshot
|
|
||||||
:export-vendors
|
|
||||||
:export-transactions2
|
|
||||||
:aggregated-sales-export
|
|
||||||
:export-raw
|
|
||||||
:export-invoices
|
|
||||||
:export-clients
|
|
||||||
:export-accounts
|
|
||||||
:export-ntg-account-snapshot
|
|
||||||
:export-ledger}] ;; TODO SSR icky
|
|
||||||
(if (and (not= (:version session) current-session-version)
|
|
||||||
|
|
||||||
(not (whitelist route) )
|
|
||||||
(not (whitelist (:handler route)) )
|
|
||||||
is-normal-route?)
|
is-normal-route?)
|
||||||
(cond
|
(cond
|
||||||
(or (= :graphql (:handler route))
|
(or (= :graphql (:handler route))
|
||||||
|
|||||||
@@ -419,7 +419,8 @@
|
|||||||
(audit-transact (conj removing-payments updated-payment)
|
(audit-transact (conj removing-payments updated-payment)
|
||||||
identity)
|
identity)
|
||||||
|
|
||||||
(html-response (row* (:identity request) updated-payment {:delete-after-settle? true :class "live-removed"})
|
(html-response (row* (:identity request) updated-payment {:delete-after-settle? true :class "live-removed"
|
||||||
|
:request request})
|
||||||
:headers {"hx-retarget" (format "#entity-table tr[data-id=\"%d\"]" (:db/id check))})))
|
:headers {"hx-retarget" (format "#entity-table tr[data-id=\"%d\"]" (:db/id check))})))
|
||||||
|
|
||||||
;; TODO use decoding here
|
;; TODO use decoding here
|
||||||
|
|||||||
@@ -18,7 +18,8 @@
|
|||||||
[venia.core :as v]))
|
[venia.core :as v]))
|
||||||
|
|
||||||
(defn maybe-add-x-clients [headers]
|
(defn maybe-add-x-clients [headers]
|
||||||
(if (mc/validate client-selection-schema (:selected-clients @re-frame.db/app-db))
|
(if (and (mc/validate client-selection-schema (:selected-clients @re-frame.db/app-db))
|
||||||
|
(not (get headers "x-clients")))
|
||||||
(assoc headers "x-clients" (.stringify js/JSON (clj->js (:selected-clients @re-frame.db/app-db))))
|
(assoc headers "x-clients" (.stringify js/JSON (clj->js (:selected-clients @re-frame.db/app-db))))
|
||||||
headers))
|
headers))
|
||||||
|
|
||||||
|
|||||||
@@ -64,10 +64,10 @@
|
|||||||
(.getItem js/localStorage)
|
(.getItem js/localStorage)
|
||||||
not-empty
|
not-empty
|
||||||
(.parse js/JSON)
|
(.parse js/JSON)
|
||||||
js->clj)
|
js->clj
|
||||||
|
( #(mc/decode client-selection-schema % client-selection-transformer)))
|
||||||
(catch js/Error e
|
(catch js/Error e
|
||||||
:all))
|
:all))
|
||||||
last-selected-clients (mc/decode client-selection-schema last-selected-clients client-selection-transformer)
|
|
||||||
jwt-data (some-> token jwt->data)
|
jwt-data (some-> token jwt->data)
|
||||||
selected-client-assignment (cond (and token
|
selected-client-assignment (cond (and token
|
||||||
(= "admin" (get jwt-data "user/role"))
|
(= "admin" (get jwt-data "user/role"))
|
||||||
@@ -208,7 +208,6 @@
|
|||||||
[with-user]
|
[with-user]
|
||||||
(fn [{:keys [db user]} [_ client]]
|
(fn [{:keys [db user]} [_ client]]
|
||||||
(let [client-identifier (or (:id client) client)]
|
(let [client-identifier (or (:id client) client)]
|
||||||
|
|
||||||
{:http {:token user
|
{:http {:token user
|
||||||
:method :put
|
:method :put
|
||||||
:uri (str (bidi/path-for ssr-routes/only-routes
|
:uri (str (bidi/path-for ssr-routes/only-routes
|
||||||
@@ -216,6 +215,14 @@
|
|||||||
:request-method :put)
|
:request-method :put)
|
||||||
"?"
|
"?"
|
||||||
(url/map->query {:search-client client-identifier}))
|
(url/map->query {:search-client client-identifier}))
|
||||||
|
:headers {"x-clients"
|
||||||
|
(.stringify js/JSON
|
||||||
|
(clj->js (cond (= :all client-identifier)
|
||||||
|
"all"
|
||||||
|
(= :mine client-identifier)
|
||||||
|
"mine"
|
||||||
|
:else
|
||||||
|
{:selected [client-identifier]})))}
|
||||||
:on-success [::swapped-client client client-identifier]}})))
|
:on-success [::swapped-client client client-identifier]}})))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
|
|||||||
@@ -21,6 +21,6 @@
|
|||||||
|
|
||||||
[:img {:src "/img/logo-big.png"}]
|
[:img {:src "/img/logo-big.png"}]
|
||||||
[:div
|
[:div
|
||||||
[:a.button.is-large.is-primary {:href (doto (login-url (get (:query (url/url (.-location js/window))) "redirect-to")) println)} "Login with Google"]]]
|
[:a.button.is-large.is-primary {:href (login-url (get (:query (url/url (.-location js/window))) "redirect-to"))} "Login with Google"]]]
|
||||||
[:p.has-text-gray
|
[:p.has-text-gray
|
||||||
"Copyright Integreat 2018"]]]]]])
|
"Copyright Integreat 2018"]]]]]])
|
||||||
|
|||||||
Reference in New Issue
Block a user