Permalink
Browse files

Used destructuring on openid-callback to simplify code a bit

  • Loading branch information...
1 parent 9f98be4 commit 0efed6aa33a2e7148f354425b39a20c9402cfc96 @chrismgray committed Dec 14, 2011
Showing with 5 additions and 7 deletions.
  1. +5 −7 src/foreclojure/login.clj
@@ -157,11 +157,9 @@
;; doesn't work. Thus, I'll make a little hack around that.
(def openid-sessions (atom {}))
-(defn do-openid-login [r]
- (let [openid-url (-> r :form-params (get "openid-url"))
- cookies (get r :cookies)
- redir (openid/redirect openid-url {} openid-callback-url)
- sess (-> cookies (get "ring-session") :value)]
+(defn do-openid-login [openid-url session-value]
+ (let [redir (openid/redirect openid-url {} openid-callback-url)
+ sess session-value]
(swap! openid-sessions #(assoc % sess (:session redir)))
(dissoc redir :session)))
@@ -174,8 +172,8 @@
(GET "/login" [location] (my-login-page location))
(POST "/login" {{:strs [user pwd]} :form-params}
(do-login user pwd))
- (POST "/openid-login" [:as r]
- (do-openid-login r))
+ (POST "/openid-login" {{:strs [openid-url]} :form-params {:strs [ring-session]} :cookies}
+ (do-openid-login openid-url (:value ring-session)))
(GET "/openid-callback" [:as r]
(do-openid-callback r))

0 comments on commit 0efed6a

Please sign in to comment.