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

Commit

Permalink
session middleware short circuit (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 authored Jun 11, 2019
1 parent ed40278 commit e6f61b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
Package.pins
DerivedData/
Package.resolved
.swiftpm

1 change: 0 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// swift-tools-version:4.0
import PackageDescription
import Foundation

let package = Package(
name: "Auth",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ public final class AuthenticationSessionsMiddleware<A>: Middleware where A: Sess

/// See Middleware.respond
public func respond(to req: Request, chainingTo next: Responder) throws -> Future<Response> {
// if the user has already been authenticated
// by a previous middleware, continue
if try req.isAuthenticated(A.self) {
return try next.respond(to: req)
}

let future: Future<Void>
if let aID = try req.authenticatedSession(A.self) {
// try to find user with id from session
Expand Down

0 comments on commit e6f61b4

Please sign in to comment.