From a6b480af09369c1a40ff13e4d681b318957d843a Mon Sep 17 00:00:00 2001 From: "paul.rutledge" Date: Tue, 25 Jul 2017 10:49:10 -0500 Subject: [PATCH] issue new session on new auth #155 --- .gitignore | 4 +++- src/cemerick/friend.clj | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index bbc51b1..d1e6309 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,9 @@ /lib /classes /checkouts +/.idea pom.xml* +*.iml *.jar *.class .lein-deps-sum @@ -12,4 +14,4 @@ pom.xml* .project .settings -.externalToolBuilders +.externalToolBuilders \ No newline at end of file diff --git a/src/cemerick/friend.clj b/src/cemerick/friend.clj index b046daa..47f9002 100644 --- a/src/cemerick/friend.clj +++ b/src/cemerick/friend.clj @@ -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