parent
cfb70fbbf6
commit
62a86ec5fb
@ -0,0 +1,16 @@
|
||||
(ns wanijo.schema.middleware
|
||||
(:require [wanijo.schema.domain :as domain]))
|
||||
|
||||
(defn wrap-user-schemas [handler]
|
||||
(fn [req]
|
||||
(if-let [uuid (get-in req [:session :uuid])]
|
||||
(let [created (domain/all-created-by! uuid)
|
||||
created-uids (map :uuid created)
|
||||
others (filter (fn [other]
|
||||
(not (some (partial = (:uuid other))
|
||||
created-uids)))
|
||||
(domain/all!))]
|
||||
(handler (-> req
|
||||
(assoc-in [:session :created-schemas] created)
|
||||
(assoc-in [:session :other-schemas] others))))
|
||||
(handler req))))
|
Loading…
Reference in new issue