Skip to content

Commit

Permalink
issue new session on new auth cemerick#155
Browse files Browse the repository at this point in the history
  • Loading branch information
paul.rutledge committed Jul 25, 2017
1 parent 12c5b66 commit a6b480a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
/lib
/classes
/checkouts
/.idea
pom.xml*
*.iml
*.jar
*.class
.lein-deps-sum
Expand All @@ -12,4 +14,4 @@ pom.xml*
.project
.settings

.externalToolBuilders
.externalToolBuilders
12 changes: 11 additions & 1 deletion src/cemerick/friend.clj
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,21 @@ Equivalent to (complement current-authentication)."}
(assoc :session (:session request))
(assoc-in [:session ::unauthorized-uri] (util/original-url request))))

(defn- mark-session-recreate
"Instructs ring to issue a new session along with the response."
[session]
(when session
(vary-meta session assoc :recreate true)))

(defn authenticate-response
"Adds to the response's :session for responses with a :friend/ensure-identity-request key."
[response request]
(if-let [new-request (:friend/ensure-identity-request response)]
(ensure-identity (dissoc response :friend/ensure-identity-request) new-request)
(->
response
(dissoc :friend/ensure-identity-request)
(ensure-identity new-request)
(update-in [:session] mark-session-recreate))
(dissoc response :friend/ensure-identity-request)))

(defn- retry-request
Expand Down

0 comments on commit a6b480a

Please sign in to comment.