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