Builds client SSR approach, sunsets old cljs.

This commit is contained in:
2024-01-09 21:40:43 -08:00
parent d824cdfff4
commit 8063a8fcbd
74 changed files with 4603 additions and 4047 deletions

View File

@@ -1,11 +1,25 @@
(ns auto-ap.permissions)
;; TODO after getting rid of cljs, use malli schemas to decode this
(defn get-client-id [client]
(cond (nat-int? client)
client
(:db/id client)
(:db/id client)
:else
nil))
(defn can? [user {:keys [client subject activity]}]
(let [role (or (:user/role user) (:role user) user)]
(println "ROLE IS" role)
(let [role (or (:user/role user) (:role user) user)
client-id (get-client-id client)]
(cond (#{:user-role/admin "admin"} role)
true
(and client-id (not (get (into #{} (map :db/id (:clients user))) client-id)))
false
(#{:user-role/power-user "power-user"} role)
(cond
(#{:invoice-page :payment-page :my-company-page :transaction-page :ledger-page} subject)
@@ -49,6 +63,9 @@
(= [:vendor :edit] [subject activity])
true
(= [:signature :edit] [subject activity])
true
:else false)
:else