I had to do this again in another project so I tried Chas' suggestion. It 
is much simpler than my earlier solution. 

For anyone else doing this in the future, here's how you can write it:

(defn check-workflow-result

  "check if the response contains and auth-map. If so, notify the event bus"

  [request response]

  (when (friend/auth? response)

    (event-bus/fire :session-start

      {:user-agent (get-in request [:headers "user-agent"])

       :ip-address (:remote-addr request)

      })))


(defn wrap [f]

  (fn [request]

    (let [response (f request)]      

      (check-workflow-result request response)      

      response)))


(def friend-interceptor

  (friend-authenticate-interceptor

   {:allow-anon? true        

    :unauthorized-handler (fn [request] (ring-resp/redirect "/thanks"))

    :workflows [(wrap

                  (oauth2/workflow

                    {:credential-fn get-friend-creds

                   :login-uri "/login"                                   

              :client-config (authentication/get-oauth-config)

              :uri-config authentication/uri-config-sfdc

              }))]}))

-- 
-- 
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
--- 
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to