            (= 204 (set-user-have-verified-email
                    request-headers api-root user-id)))))
 
-  (create-user [{api-root :api-root} request-headers email]
+  (create-user [{:keys [api-root]} request-headers email]
     (client/post (format "%s/users" api-root)
                  {:body (json/encode
                    {"username" email

      :body json/decode))

(defn request-headers
  "Create a partial request with json content type and a valid bearer token.
   This token can be used for a batch of requests. This enables us to not have
   to get a new token for every request to Keycloak but one for task we have."
  [{:keys [openid-config credentials]}]
  (let [params (merge {"grant_type" "client_credentials"}
                      credentials)


(defn tenant-member?
  "Return true for both members and admins."
  [{:keys [api-root] :as keycloak} tenant email]
  (let [request-headers (request-headers keycloak)]
    (if-let [user-id
             (get (fetch-user-by-email request-headers api-root email) "id")]
