More reliability with company dropdown
This commit is contained in:
@@ -325,7 +325,7 @@
|
||||
(wrap-session {:store (cookie-store
|
||||
{:key
|
||||
(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-params)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
(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
|
||||
;; once it is, it should just use redirects based on headers
|
||||
;; no header=use default, mismatch header=redirect to login
|
||||
(def current-session-version 1)
|
||||
(def current-session-version 2)
|
||||
(defn wrap-session-version
|
||||
[handler]
|
||||
(fn [request]
|
||||
@@ -13,28 +14,9 @@
|
||||
(:uri request)
|
||||
:request-method (:request-method request))
|
||||
is-normal-route? (or (keyword? route)
|
||||
(keyword? (:handler route)))
|
||||
whitelist #{:fastlink :oauth :login :health :raw-query :results-csv-query :results-json-query
|
||||
: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)
|
||||
(keyword? (:handler route)))] ;; TODO SSR icky
|
||||
(if (and (not= (:version session current-session-version) current-session-version)
|
||||
|
||||
(not (whitelist route) )
|
||||
(not (whitelist (:handler route)) )
|
||||
is-normal-route?)
|
||||
(cond
|
||||
(or (= :graphql (:handler route))
|
||||
|
||||
@@ -419,7 +419,8 @@
|
||||
(audit-transact (conj removing-payments updated-payment)
|
||||
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))})))
|
||||
|
||||
;; TODO use decoding here
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
[venia.core :as v]))
|
||||
|
||||
(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))))
|
||||
headers))
|
||||
|
||||
|
||||
@@ -64,10 +64,10 @@
|
||||
(.getItem js/localStorage)
|
||||
not-empty
|
||||
(.parse js/JSON)
|
||||
js->clj)
|
||||
js->clj
|
||||
( #(mc/decode client-selection-schema % client-selection-transformer)))
|
||||
(catch js/Error e
|
||||
:all))
|
||||
last-selected-clients (mc/decode client-selection-schema last-selected-clients client-selection-transformer)
|
||||
jwt-data (some-> token jwt->data)
|
||||
selected-client-assignment (cond (and token
|
||||
(= "admin" (get jwt-data "user/role"))
|
||||
@@ -208,7 +208,6 @@
|
||||
[with-user]
|
||||
(fn [{:keys [db user]} [_ client]]
|
||||
(let [client-identifier (or (:id client) client)]
|
||||
|
||||
{:http {:token user
|
||||
:method :put
|
||||
:uri (str (bidi/path-for ssr-routes/only-routes
|
||||
@@ -216,6 +215,14 @@
|
||||
:request-method :put)
|
||||
"?"
|
||||
(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]}})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
|
||||
[:img {:src "/img/logo-big.png"}]
|
||||
[: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
|
||||
"Copyright Integreat 2018"]]]]]])
|
||||
|
||||
Reference in New Issue
Block a user