Skip to content

Instantly share code, notes, and snippets.

@thheller
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thheller/cda2a325c5e36b5f479c to your computer and use it in GitHub Desktop.
Save thheller/cda2a325c5e36b5f479c to your computer and use it in GitHub Desktop.
(defn get-user-from-request [request]
(when-let [ident (get-in request [:session ::friend/identity :current])]
(magic/user-by-id (get-in request [:myapp :system :db]) ident)))
(defn wrap-user
"Add user information to the request map if logged in."
[handler]
(fn [request]
(if-let [user (get-user-from-request request)]
(handler (assoc-in request [:myapp :user] user))
(handler request)
)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment