                       :never (t/years 1000))
                     (t/plus (t/now))
                     (c/to-long))
-        mac (hmac hmac-secret (str nonce group-id expiry))]
+        mac (hmac (config :hmac-secret) (str nonce group-id expiry))]
     (str (config :site-url) "/invite?group-id=" group-id "&nonce=" nonce
          "&expiry=" expiry "&mac=" mac)))
 

  [group-id]
  (let [now (.getTime (java.util.Date.))
        group (db/get-group group-id)
        form-hmac (hmac hmac-secret (str now group-id))
        api-domain (:api-domain config)]
    (clostache/render-resource "templates/link_signup.html.mustache"
                               {:api-domain api-domain

            [chat.server.cache :refer [cache-set! cache-get cache-del! random-nonce]]
            [chat.server.crypto :refer [hmac constant-comp]]
            [chat.server.db :as db]
            [environ.core :refer [env]]
            [braid.server.conf :refer [config]]))

(when (and (= (env :environment) "prod") (empty? (env :hmac-secret)))
  (println "WARNING: No :hmac-secret set, using an insecure default."))

(defn verify-hmac
  [mac data]
  (constant-comp
    mac
    (hmac (config :hmac-secret) data)))

(defn verify-invite-nonce
  "Verify that the given nonce is valid for the invite"
