Builds client SSR approach, sunsets old cljs.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user