 
 (comment
   (require '[konserve.store :refer [new-mem-store]])
+
   (let [in (chan)
         out (chan)
         [new-in new-out] (auth (<!! (new-mem-store (atom {"user@mail.com" {1 {:causal-order {10 []}}}})))
                                (fn [users] (go (zipmap users (repeat "P4ssw0rd"))))
-                               (fn [token] (if (= (:password token) "password")
-                                            (dissoc token :password)))
+                               (fn [token] (if (= (:password token) "P4ssw0rd")
+                                            true
+                                            false))
                                (atom #{})
                                [in out])]
+
+
+    (go-loop [o (<!! out)]
+      (when o
+        (println "OUT" o)
+        (recur (<!! out))))
+
+    (go-loop [o (<!! new-in)]
+      (when o
+        (println "NEW-IN" o)
+        (recur (<!! new-in))))
+
     (>!! in (with-meta {:topic :meta-pub :metas {"user@mail.com" {1 {:causal-order {10 []
-                                                                                    20 [10]}}}}}
+                                                                                    20 [10]}}}
+                                                 "eve@mail.com" {1 {:causal-order {20 []}}}}}
               {:host "127.0.0.1"}))
-    (println "OUT:" (<!! out))
-    (>!! in {:topic ::auth :users {"user@mail.com" "password"}})
-    (println "NEW-IN:" (<!! new-in))
-    #_(>!! in {:topic ::auth-required
-               :users #{"eve@mail.com"}})
-    #_(println "OUT:" (<!! out))))
+    (>!! in {:topic ::auth :users {"user@mail.com" "Passw0rd" "eve@mail.com" "Password"}})
+    (>!! in {:topic ::auth :users {"user@mail.com" "P4ssw0rd" "eve@mail.com" "Passw0rd"}})
+    (>!! in {:topic ::auth :users {"eve@mail.com" "Passw0rd"}})
+    (>!! in {:topic ::auth :users {"eve@mail.com" "Passw0rd"}})
+    (>!! in {:topic ::auth :users {"eve@mail.com" "Passw0rd"}})
+    (>!! in {:topic ::auth :users {"eve@mail.com" "Passw0rd"}})
+    (>!! in {:topic ::auth :users {"eve@mail.com" "Passw0rd"}})
+    (>!! in {:topic ::auth :users {"eve@mail.com" "Passw0rd"}})
+    (>!! in {:topic ::auth :users {"eve@mail.com" "Passw0rd"}})
+    (>!! in {:topic ::auth :users {"eve@mail.com" "P4ssw0rd"}}))
+
+  (println "\n")
+
+
+  )

  "Authentication middleware for geschichte."
  (:require [geschichte.platform-log :refer [debug info warn error]]
            [konserve.protocols :refer [IEDNAsyncKeyValueStore -assoc-in -get-in -update-in]]
            [clojure.set :as set]
            [postal.core :refer [send-message]]
            #+clj [clojure.core.async :as async

        pub-ch (chan)
        auth-req-ch (chan)
        register (chan)] ;; TODO
    (sub p :meta-pub pub-ch)
    (meta-published pub-ch store trusted-hosts credential-fn [new-in out])

    (sub p ::auth-required auth-req-ch)
    (auth-required auth-req-ch auth-fn out)

    (sub p :unrelated new-in)
