More reliability with company dropdown

This commit is contained in:
Bryce
2024-04-10 09:30:33 -07:00
parent 162d24c470
commit 8da7eaaf46
6 changed files with 21 additions and 30 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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