             [d-cent.utils :as utils]
             [d-cent.workflows.twitter :refer [twitter-workflow]]))
 
+;; Custom ring middleware
+
+(defn wrap-api-authorize [handler roles]
+  (fn [request]
+    (if (friend/authorized? roles friend/*identity*)
+      (handler request)
+      {:status 401})))
+
+;; Handlers
+
 (defn index [{:keys [t' locale]}]
   (let [username (get (friend/current-authentication) :username)]
   (rendered-response index-page {:translation t'

  (simple-response "blah"))

(defn email-capture-post [request]
  (if (friend/authorized? #{:signed-in} friend/*identity*)
    {:status 200}
    {:status 401}))

(defn new-objective-link [stored-objective]
  (str utils/host-url "/objectives/" (:_id stored-objective)))


(defn objective-new-link-page [{:keys [t' locale]} stored-objective]
  (let [username (get (friend/current-authentication) :username)]

                                 :doc-title (t' :index/doc-title)
                                 :doc-description (t' :index/doc-description)
                                 :signed-in (when username true)})))

(defn sign-in [{:keys [t' locale]}]
  (let [username (get (friend/current-authentication) :username)]
