                              :cylon/identity identity})
 
                      (cookies-response {:status 302
-                       :headers {"Location"
-                                 (format
-                                  ;; TODO: Replace this with the callback uri
-                                  "%s?code=%s&state=%s"
-                                  callback-uri code state
-                                  )}
-                       :cookies {SESSION-ID (->cookie session)}}))))
+                                        :headers {"Location"
+                                                  (format
+                                                   ;; TODO: Replace this with the callback uri
+                                                   "%s?code=%s&state=%s"
+                                                   callback-uri code state
+                                                   )}
+                                        :cookies {SESSION-ID (->cookie session)}}))))
                ;; Fail
                {:status 302
-                :headers {"Location" (format "%s" (path-for (:modular.bidi/routes req) ::get-authenticate-form))}
+                :headers {"Location" (format "%s" (path-for (:modular.bidi/routes req) ::get-login-form))}
                 :body "Try again"})))
 
          wrap-params wrap-cookies s/with-fn-validation)

  (request-handlers [this]
    {::authorize
     (-> (fn [req]
        ;; TODO Establish whether the user-agent is already authenticated.
        ;; If not, create a session with client-id, scope and state and redirect to the login form
        (if-let [session
                 (get-session
                  (:session-store this)
                  (-> req cookies-request :cookies (get SESSION-ID) :value))]
          ;; TODO Obey the 'prompt' value in OpenID/Connect
          (do
            (infof "Hi - it appears you're already logged in, session is %s" (pr-str session))
            {:status 302
             :headers {"Location" (path-for (:modular.bidi/routes req) ::get-authenticate-form)}})
          (let [session (create-session!
                         (:session-store this)
                         {:client-id (-> req :query-params (get "client_id"))
                          :scope (-> req :query-params (get "scope"))
                          :state (-> req :query-params (get "state"))
                          })]
            (infof "Hi - it appears you're not already logged in, so I'm going to create a session for you and redirect you")
            (cookies-response
                      {:status 302
                       :headers {"Location" (path-for (:modular.bidi/routes req) ::get-authenticate-form)}
                       :cookies {SESSION-ID (->cookie session)}}))))
         wrap-params)

     ::get-authenticate-form
     (->
      (fn [req]
        {:status 200

                  [:p [:a {:href (path-for (:modular.bidi/routes req) :cylon.impl.signup/signup-form)} "Signup"]]]])})
      wrap-params)

     ::post-login-form
     (-> (fn [req]
           (let [params (-> req :form-params)
                 identity (get params "user")
