         (for [e errors] [:div e])])
      [:form {:action "" :method "post"}
       [:div {:class "input-wrapper"}
-       [:input {:type "text" :name "username" :placeholder "Write your username here..."}]]
+       [:input {:type "text" :name "username"
+                :placeholder "Write your username here..."}]]
       [:div {:class "input-wrapper"}
-       [:input {:type "password" :name "password" :placeholder "Write your password here..."}]]
+       [:input {:type "password" :name "password"
+                :placeholder "Write your password here..."}]]
       [:div {:class "input-wrapper"}
        [:input {:type "submit" :value "Submit"}]]]])))
 
+
+;; A simple function that has the responsability of authenticate the incomoning
+;; credentials on login post request. In the current implementation it just
+;; checks if a user and password matches to the builtin "user" representation,
+;; but in your implementation this function may access to the database or any
+;; other source for authenticate. This is just a example.
 
 (defn- authenticate
   [username, password]
   (when (and (= username "admin")
              (= password "123123"))
-    {:userid 1}))
+    {:username "Admin"}))
+
+;; A hanlder that simply render the login page for GET requests.
 
 (defn login-page
   [context]
-  (-> (render-login-page ["foo", "bar"])
+  (-> (render-login-page)
       (http/ok {:content-type "text/html"})))
+
+;; A handler that clears the session and redirect to the home page.
+
+(defn logout-page
+  [context]
+  (let [session (:session context)]
+    (swap! session dissoc :identity)
+    (http/found "/")))
+
+;; A handler that handles the POST requests for login page.
 
 (defn login-submit
   [context]

(ns website.core
  (:require [clojure.java.io :as io]
            ;; [hiccup.core :as hc]
            [hiccup.page :as hc]
            [catacumba.core :as ct]
            [catacumba.handlers :as hs]

(def auth-backend
  (auth/session-backend))

;; Define the application routes using `ct/routes`
;; function from catacumba.

(def app
  (ct/routes [[:prefix "assets"
               [:assets "resources/public"]]
              [:scope
               [:any (hs/session {:storage :inmemory})]
               [:any (hs/auth auth-backend)]
               [:get home-page]
               [:get "logout" logout-page]
               [:by-method "login"
                [:get login-page]
                [:post login-submit]]]]))

;; Define the main entry point that starts the catacumba
;; server un the port 5051.

(defn -main
  "The main entry point to your application."
