After the failed login, I am redirected here:

http://localhost:30001/login?&login_failed=Y&username=

and where I pprint the request, I see this in the terminal:

 :params {"" nil, "login_failed" "Y", "username" ""},






On Monday, April 29, 2013 3:09:09 PM UTC-4, larry google groups wrote:
>
> I will re-phrase the question. Can anyone suggest a reason why the form 
> params would be not register with these middlewares in place? 
>
> (def app
>   (-> app-routes
>       (friend/authenticate {:workflows [(workflows/interactive-form)]
>                             :credential-fn (partial 
> creds/bcrypt-credential-fn users)})
>       (wrap-session {:cookie-name "timeout-session" :cookie-attrs 
> {:max-age 90}})
>       (wrap-cookies)
>       (wrap-multipart-params)
>       (wrap-params)
>       (wrap-nested-params)
>       (wrap-keyword-params)))
>
> The problem is specific to "friend". I have other forms, which are not 
> protected by "friend" and they work just fine. 
>
> But with "friend", when I pprint the request to the terminal, I only see 
> stuff like:
>
> :params {},
>  :form-params {},
>  :multipart-params {},
>
> I print the request on the first line of the login function: 
>
> (defn login [request]
>   (println (pp/pprint request))
>   "2013-03-01 - the default name of the function expected by the Friend 
> authorization library."
>   (timbre/spy :debug " the return value of the login page: "
>               (let [login-template (enlive/html-resource 
> "templates/login.html")
>                     login-html  (apply str (enlive/emit* login-template))
>                     layout (enlive/html-resource "templates/admin.html")
>                     layout (enlive/transform layout
>                                              [:#outer]
>                                              (enlive/html-content 
> login-html))
>                     html (apply str (enlive/emit* layout))
>                                                               ]
>                 (response html))))
>
>
> my routes:
>
> (defroutes app-routes
>   (ANY "/" request (home-page request))
>   (ANY "/login" request (login request))
>   (friend/logout (ANY "/logout" request (ring.util.response/redirect "/")))
>   (GET "/serve-file/:file-id" request (serve-file request))
>   (GET "/home/:slides-id" request (home-page request))
>   (GET "/action/:action-to-perform" request (action request))
>   (GET "/admin" request (friend/authorize #{::admin} (admin request)))
>   (GET "/admin/list/:item-type" [item-type] (admin-list item-type))
>   (GET "/admin/edit/:item-type" request (admin-forms request))
>   (GET "/admin/edit/:item-type/:item-name" request (admin-forms request))
>   (POST "/admin/edit/:item-type/:item-name" request 
> (admin-process-form-input request))
>   (POST "/admin/edit/:item-type" request (admin-process-form-input 
> request))
>   (GET "/admin/delete/:item-type/:item-name" request 
> (admin-delete-ask-for-confirmation request))
>   (POST "/admin/delete/:item-type/:item-name" request 
> (admin-delete-finalized request))
>   (GET "/admin/clone/:item-type/:item-name" request (admin-clone-this-item 
> request))
>   (GET "/admin/preview/:item-type/:item-name" request (admin-preview 
> request))
>   (GET "/admin/upload" request (admin-upload request))
>   (route/resources "/")
>   (route/not-found "Page not found"))
>
>
> I have tried several things and nothing has given me much of a clue, so 
> any suggestions are welcome. 
>
>
>
>
>
> On Friday, April 26, 2013 2:16:22 PM UTC-4, larry google groups wrote:
>>
>> I have tried putting (friend/authenticate) at the beginning and end of 
>> this block:
>>
>>
>> (def app
>>   (-> app-routes
>>       (wrap-session {:cookie-name "timeout-session" :cookie-attrs 
>> {:max-age 90}})
>>       (wrap-cookies)
>>       (wrap-multipart-params)
>>       (wrap-params)
>>       (wrap-nested-params)
>>       (wrap-keyword-params)
>>       (friend/authenticate {:workflows [(workflows/interactive-form)]
>>                             :credential-fn (partial 
>> creds/bcrypt-credential-fn users)
>>                             :login-uri "/login"
>>                             :unauthorized-redirect-uri "/login" 
>>                             :default-landing-uri "/admin"})))
>>
>>
>> and: 
>>
>>
>> (def app
>>   (-> app-routes
>>       (friend/authenticate {:workflows [(workflows/interactive-form)]
>>                             :credential-fn (partial 
>> creds/bcrypt-credential-fn users)
>>                             :login-uri "/login"
>>                             :unauthorized-redirect-uri "/login" 
>>                             :default-landing-uri "/admin"})
>>       (wrap-session {:cookie-name "timeout-session" :cookie-attrs 
>> {:max-age 90}})
>>       (wrap-cookies)
>>       (wrap-multipart-params)
>>       (wrap-params)
>>       (wrap-nested-params)
>>       (wrap-keyword-params)
>> ))
>>
>>
>> but that doesn't seem to matter. 
>>
>> I defined my one user in the namespace as: 
>>
>> (def users {"admin" {:username "admin"
>>                      :password (creds/hash-bcrypt "47010thave")
>>                      :roles #{::admin}}})
>>
>> If I point my broswer here:
>>
>> localhost:30000/admin
>>
>> I get redirected to here:
>>
>> localhost:30000/admin
>>
>> I then fill in this form:
>>
>> <form action="/login" method="POST">Username: <input type="text" name="
>> username" /><br />Password: <input type="password" name="password" /><br 
>> />
>> <input type="submit" name="submit" value="submit" /><br /></form>
>> If I print the request to the terminal, the form params are all blank:
>>
>> {:ssl-client-cert nil,
>>  :remote-addr "0:0:0:0:0:0:0:1",
>>  :scheme :http,
>>  :query-params {"username" "", "login_failed" "Y", "" nil},
>>  :session {},
>>  :cemerick.friend/auth-config
>>  {:unauthorized-redirect-uri "/login",
>>   :allow-anon? true,
>>   :default-landing-uri "/admin",
>>   :login-uri "/login",
>>   :credential-fn
>>   #<core$partial$fn__4070 clojure.core$partial$fn__4070@1627fd1>,
>>   :workflows
>>   [#<workflows$interactive_form$fn__4503 
>> cemerick.friend.workflows$interactive_form$fn__4503@28ee2be9>],
>>   :unauthenticated-handler
>>   #<Var@557db906:
>>     #<friend$default_unauthenticated_handler 
>> cemerick.friend$default_unauthenticated_handler@114e8c69>>,
>>   :unauthorized-handler
>>   #<Var@3d93cfcb:
>>     #<friend$default_unauthorized_handler 
>> cemerick.friend$default_unauthorized_handler@1aaad63a>>},
>>  :form-params {},
>>  :multipart-params {},
>>  :request-method :get,
>>  :query-string "&login_failed=Y&username=",
>>  :route-params {},
>>  :content-type nil,
>>  :cookies {"timeout-kiosk" {:value "timeout-kiosk3312112"}},
>>  :uri "/login",
>>  :server-name "localhost",
>>  :params {"" nil, "login_failed" "Y", "username" ""},
>>  :headers
>>  {"user-agent"
>>   "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.31 
>> (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537\
>> .31",
>>   "cookie" "timeout-kiosk=timeout-kiosk3312112",
>>   "accept-charset" "ISO-8859-1,utf-8;q=0.7,*;q=0.3",
>>   "accept"
>>   "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
>>   "host" "localhost:30001",
>>   "referer" "http://localhost:30001/login?&login_failed=Y&username=";,
>>   "cache-control" "max-age=0",
>>   "accept-encoding" "gzip,deflate,sdch",
>>   "accept-language" "en-US,en;q=0.8",
>>   "connection" "keep-alive"},
>>  :content-length nil,
>>  :server-port 30001,
>>  :character-encoding nil,
>>  :body #<HttpInput org.eclipse.jetty.server.HttpInput@25796d08>}
>>
>>
>>
>> I have defined the routes like this:
>>
>>
>> (defroutes app-routes
>>   (ANY "/" request (home-page request))
>>   (GET "/login" request (login request))
>>   (friend/logout (ANY "/logout" request (ring.util.response/redirect 
>> "/")))
>>   (GET "/serve-file/:file-id" request (serve-file request))
>>   (GET "/home/:slides-id" request (home-page request))
>>   (GET "/action/:action-to-perform" request (action request))
>>   (GET "/admin" request
>>        (friend/authorize #{::admin}  (admin request)))
>>   (GET "/admin/list/:item-type" [item-type] (admin-list item-type))
>>   (GET "/admin/edit/:item-type" request (admin-forms request))
>>   (GET "/admin/edit/:item-type/:item-name" request (admin-forms request))
>>   (POST "/admin/edit/:item-type/:item-name" request 
>> (admin-process-form-input request))
>>   (POST "/admin/edit/:item-type" request (admin-process-form-input 
>> request))
>>   (GET "/admin/delete/:item-type/:item-name" request 
>> (admin-delete-ask-for-confirmation request))
>>   (POST "/admin/delete/:item-type/:item-name" request 
>> (admin-delete-finalized request))
>>   (GET "/admin/clone/:item-type/:item-name" request 
>> (admin-clone-this-item request))
>>   (GET "/admin/preview/:item-type/:item-name" request (admin-preview 
>> request))
>>   (GET "/admin/upload" request (admin-upload request))
>>   (route/resources "/")
>>   (route/not-found "Page not found"))
>>
>>
>> And the login function looks like this:
>>
>> (defn login [request]
>>   (println (pp/pprint request))
>>   "2013-03-01 - the default name of the function expected by the Friend 
>> authorization library."
>>   (timbre/spy :debug " the return value of the login page: "
>>               (let [login-template (enlive/html-resource 
>> "templates/login.html")
>>                     login-html  (apply str (enlive/emit* login-template))
>>                     layout (enlive/html-resource "templates/admin.html")
>>                     layout (enlive/transform layout
>>                                              [:#outer]
>>                                              (enlive/html-content 
>> login-html))
>>                     html (apply str (enlive/emit* layout))
>>                                                               ]
>>                 (response html))))
>>
>>
>>
>> Any thoughts about why the form inputs are empty? 
>>
>>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to