Reputation: 23300
I'm fairly new to clojure, and I'm trying to add an authentication system to a compujure app and for that I'm using cemerick.friend.
All the routes are working fine, but I'm never able to login, even when using a dummy in memory database (if you can call it that).
The problem, I believe, is on the cemerick.friend.credentials/bcrypt-credential-fn
, which is never validating my credentials.
Here's a gist with the relevant code: https://gist.github.com/zamith/5940965
Any help on how to solve this problem would be nice.
Thanks.
Upvotes: 3
Views: 633
Reputation: 84331
You want to use workflows/interactive-form
where currently you specify workflows/interactive-login-redirect
.
The latter function's purpose is to serve as the default :login-failure-handler
. What it does is perform the redirect after a failed login attempt; it certainly makes no attempt to log a user in.
You also need to remove the (resp/redirect "/signup")
from the body of the friend/authenticated
form in your "/dashboard"
route, as it's unconditionally redirecting logged in users to the signup page. (That the redirect happens is in fact proof of the user being authenticated, since otherwise the body of friend/authenticated
would not be evaluated and there's nothing else in the code which could cause a redirect to "/signup"
.)
With these two changes, the app works for me.
Upvotes: 4