Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Commit

Permalink
unauth session if no user is authed when sending response, fixes #52
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Aug 14, 2018
1 parent 2524531 commit 56593e0
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ public final class AuthenticationSessionsMiddleware<A>: Middleware where A: Sess
return future.flatMap {
// respond to the request
return try next.respond(to: req).map { res in
// if a user is authed, store in the session
if let a = try req.authenticated(A.self) {
// if a user has been authed (or is still authed), store in the session
try req.authenticateSession(a)
} else {
// if no user is authed, it's possible they've been unauthed.
// remove from session.
try req.unauthenticateSession(A.self)
}
return res
}
Expand Down

0 comments on commit 56593e0

Please sign in to comment.