Skip to content

Commit b1b1c26

Browse files
authored
Merge pull request #8 from visto9259/1.0.x
Improved AuthenticationMiddleware.php to ignore already authenticated request
2 parents 65e997c + 61004cb commit b1b1c26

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/AuthenticationMiddleware.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public function __construct(
2121
*/
2222
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
2323
{
24+
// If already authenticated
25+
if ($request->getAttribute(UserInterface::class) !== null) {
26+
return $handler->handle($request);
27+
}
2428
$user = $this->authAdapter->authenticate($request);
2529
return $handler->handle($request->withAttribute(UserInterface::class, $user));
2630
}

0 commit comments

Comments
 (0)