|
|
|
@ -8,7 +8,7 @@
|
|
|
|
|
(if-let [uuid (get-in req [:session :uuid])]
|
|
|
|
|
(handler (assoc-in req
|
|
|
|
|
[:session :schemas]
|
|
|
|
|
(db/accessible-schemas! uuid)))
|
|
|
|
|
(db/all-readable-by! uuid)))
|
|
|
|
|
(handler req))))
|
|
|
|
|
|
|
|
|
|
(defn write-permission-middleware! [schema-fn]
|
|
|
|
@ -25,15 +25,11 @@
|
|
|
|
|
(write-permission-middleware! #(get-in % [:params :uuid])))
|
|
|
|
|
|
|
|
|
|
(defn wrap-allowed-to-read!
|
|
|
|
|
([schema-fn]
|
|
|
|
|
(wrap-allowed-to-read! schema-fn
|
|
|
|
|
(fn [_]
|
|
|
|
|
(assoc (resp/redirect (path :schema-overview))
|
|
|
|
|
:flash ["No read permission for schema"]))))
|
|
|
|
|
([schema-fn not-allowed-fn]
|
|
|
|
|
(fn [handler]
|
|
|
|
|
(fn [req]
|
|
|
|
|
(let [uuid (schema-fn req)]
|
|
|
|
|
(if (db/has-user-read-permissions? uuid (-> req :session :uuid))
|
|
|
|
|
(handler req)
|
|
|
|
|
(not-allowed-fn req)))))))
|
|
|
|
|
[schema-fn]
|
|
|
|
|
(fn [handler]
|
|
|
|
|
(fn [req]
|
|
|
|
|
(let [uuid (schema-fn req)]
|
|
|
|
|
(if (db/has-user-read-permissions? uuid (-> req :session :uuid))
|
|
|
|
|
(handler req)
|
|
|
|
|
(assoc (resp/redirect (path :schema-overview))
|
|
|
|
|
:flash ["No read permission for schema"]))))))
|
|
|
|
|