Skip to content

Commit eab4f38

Browse files
committed
- CS formatting
1 parent ca783e0 commit eab4f38

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

SessionAuthenticatedMiddleware.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace Koded\Session;
1414

15-
use Koded\Http\{StatusCode, ServerResponse};
15+
use Koded\Http\{ServerResponse, StatusCode};
1616
use Koded\Stdlib\Interfaces\ConfigurationFactory;
1717
use Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
1818
use Psr\Http\Server\{MiddlewareInterface, RequestHandlerInterface};
@@ -21,7 +21,7 @@
2121
class SessionAuthenticatedMiddleware implements MiddlewareInterface
2222
{
2323
public const AUTHENTICATED = 'authenticated';
24-
public const LOGIN_URI = 'loginUri';
24+
public const LOGIN_URI = 'loginUri';
2525

2626
private $redirectTo = '/';
2727

@@ -32,17 +32,12 @@ public function __construct(ConfigurationFactory $settings)
3232

3333
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
3434
{
35-
if (true !== ($_SESSION[self::AUTHENTICATED] ?? false)) {
36-
return $this->redirect();
35+
if (true === ($_SESSION[self::AUTHENTICATED] ?? false)) {
36+
return $handler->handle($request);
3737
}
3838

39-
return $handler->handle($request);
40-
}
41-
42-
private function redirect(): ResponseInterface
43-
{
4439
// Ajax requests should be handled in the browser
45-
if (strtoupper($_SERVER['HTTP_X_REQUESTED_WITH'] ?? '') === 'XMLHTTPREQUEST') {
40+
if ('XMLHTTPREQUEST' === strtoupper($_SERVER['HTTP_X_REQUESTED_WITH'] ?? '')) {
4641
return (new ServerResponse(json_encode([
4742
'location' => $this->redirectTo,
4843
'status' => StatusCode::UNAUTHORIZED

0 commit comments

Comments
 (0)