Browse files

More refined success and failure states.

Success on receiving an OpenID now mimics the behavior of receiving a
valid username and password.
  • Loading branch information...
1 parent 6ddca11 commit d993d361c0fc5b61554f1e4ec1fb6e509bad7d62 @chrismgray committed Dec 13, 2011
Showing with 14 additions and 5 deletions.
  1. +14 −5 src/foreclojure/login.clj
@@ -131,13 +131,22 @@
(def-page openid-failure [r]
{:title "OpenID Failure"
- :content (content-page [:div [:p "Failure"]])})
+ :content (content-page {:main [:div [:p "The OpenID you provided could not be verified. Please go back and try again."]]})})
(def-page openid-success [r]
- {:title "OpenID success"
- :content (content-page [:div [:p "Success"]])})
-(def openid-sessions (atom {}))
+ (let [claimed-id (-> r :params :openid.claimed_id)
+ user {:openid claimed-id}
+ location (session/session-get :login-to)
+ db-user (fetch-one :users :where {:user })]
+ (update! :users {:user user}
+ {:$set {:last-login (java.util.Date.)}})
+ (session/session-put! :user user)
+ (session/session-delete-key! :login-to)
+ (response/redirect (or location "/problems"))))
+;; Putting the session info that openid needs in the sandbar session
+;; 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"))

0 comments on commit d993d36

Please sign in to comment.