Created
March 2, 2013 16:17
-
-
Save dpick/5071762 to your computer and use it in GitHub Desktop.
Anonymous users with friend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn credential-fn [guid] | |
(if-let [user (persistence/find-user-by-guid guid)] | |
(assoc user :roles #{:fashion.server/user}))) | |
(defn guid [request] | |
(if (empty? (:session request)) | |
(let [user (persistence/create-user {:guid (java.util.UUID/randomUUID) :password (str (java.util.UUID/randomUUID))})] | |
(workflows/make-auth (assoc user :roles #{:fashion.server/user} :identity (:guid user)) {:cemerick.friend/workflow :guid})) | |
(let [user (persistence/find-user-by-guid (get-in request [:session :cemerick.friend/identity :current]))] | |
(when user | |
(workflows/make-auth (assoc user :roles #{:fashion.server/user} :identity (:guid user)) {::cemerick.friend/workflow :guid ::friend/redirect-on-auth? false}))))) | |
(defn secure-app [app] | |
(-> app | |
(friend/authenticate { :credential-fn (partial creds/bcrypt-credential-fn credential-fn) | |
:workflows [(workflows/interactive-form) guid] }))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment