How should I debug this? What questions should I ask?

At this point, for the sake of debugging, I have everything in one
file, in one name space. I have recreated the dummy users database:


(def users {"root"{:username "lawrence"
                   :password (creds/hash-bcrypt "admin_password")
                   :roles #{::admin}
                   :created_at "2013-01-08 14:00:00"
                   :telephone-numbers [{:country "USA" :number "434
825 7694"}
                                       {:country "USA" :number "732
364 3640"}]}
            "jane" {:username "jane"
                    :password (creds/hash-bcrypt "user_password")
                    :roles #{::user}
                    :created_at "2013-01-10 16:40:34"
                    :telephone-numbers []}})


And, as far as I know, I have set up the routes with Compojure and
Friend correctly:

(defroutes app-routes
  (GET "/" request (index request))
  (GET "/search-results" request (search-results request))
  (GET "/schema" request (schema request))
  (GET "/account" request (friend/authorize #{::user} {} (account
request)))
  (GET "/admin" request (friend/authorize #{::admin} {} (admin
request)))
  (friend/logout (ANY "/logout" request (ring.util.response/redirect
"/")))
  (GET "/login" request (login request))
  (route/not-found "Page not found"))

(def app
    (-> app-routes
        (friend/authenticate {:credential-fn (partial creds/bcrypt-
credential-fn users)
                              :workflows [(workflows/interactive-
form)]})
        (wrap-resource "public")
        (wrap-session {:cookie-name "discovery-session" :cookie-attrs
{:max-age 10000 }})
        (wrap-cookies)
        (wrap-keyword-params)
        (wrap-nested-params)
        (wrap-params)))

(defn -main [& args]
  (let [port (Integer/parseInt (first args))]
    (try
      (run-jetty #'app {:port (or port 8080) :join? false})
      (catch Exception e (debug/print-error-info e)))))

When I go here:

http://localhost:40000/admin

I get redirected to here:

http://localhost:40000/login

So far, so good.

But when I try to log in, I end up with this for an URL:

http://localhost:40000/login?&login_failed=Y&username=lawrence

I am wondering how I should debug this?

The admin function looks like this:

(defn admin [request]
  (let [page-with-banner (add-banner-image-to-page)
        page-with-result (enlive/at page-with-
banner
                                    [:#trips]
                                    (enlive/content
                                     (apply str (dashboard)))
        page-string (apply str (enlive/emit* page-with-result))]
    (response page-string)))

How should I debug this? How do I find out what is not working? What
questions should I ask?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to