Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

issue new session on new auth #155 #156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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