 (def auth-backend
   (session-backend {:unauthorized-handler unauthorized-handler}))
 
-(defn home
-  [req]
+(defn home [req]
   (when (not (authenticated? req))
     (throw-unauthorized {:message "Not authorized"}))
   (render-file "templates/index.html" {:dev (env :dev?)}))

                                                                              categories))))

           (GET "/user/:id" [id] (generate-response (str "Hello user " id)))

           (not-found "Not Found"))

(def app

(defn logout [req]
  (assoc (redirect "/") :session nil))

(defn find-user [username]
  (hashers/encrypt "password"))

(defn login-authenticate [req]
  (let [username (get-in req [:form-params "username"])
        password (get-in req [:form-params "password"])
        session (:session req)
        found-password (find-user username)
        #_(get authdata (keyword username))]
    (if (and found-password (hashers/check password found-password))
      (let [next-url (get-in req [:query-params :next] "/")
            updated-session (assoc session :identity (keyword username))]
        (-> (redirect "/")
            (assoc :session updated-session)))
      (render-file "templates/login.html" {:dev (env :dev?)}))))

;;;;;;;;;;;;;;;;;;;;;;;;

(defroutes routes

           (GET "/" [] home)

           (GET "/raw" [] (render-file "templates/indexraw.html" {:dev (env :dev?)}))
