Skip to content

Commit

Permalink
Remove callExit() from AuthenticationPlugin::authenticate()
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed May 9, 2024
1 parent ad98ad2 commit aa70f48
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/Http/Middleware/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface

try {
try {
$authPlugin->authenticate();
$response = $authPlugin->authenticate();
if ($response !== null) {
return $response;
}
} catch (AuthenticationFailure $exception) {
return $authPlugin->showFailure($exception);
}
Expand Down
6 changes: 4 additions & 2 deletions src/Plugins/AuthenticationPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function setSessionAccessTime(): void
*
* @throws AuthenticationFailure
*/
public function authenticate(): void
public function authenticate(): Response|null
{
$success = $this->readCredentials();

Expand All @@ -246,7 +246,7 @@ public function authenticate(): void
'error_message' => $exception->getMessage(),
]));

$responseRenderer->callExit();
return $responseRenderer->response();
}

$this->showLoginForm();
Expand All @@ -258,6 +258,8 @@ public function authenticate(): void
$this->checkRules();
/* clear user cache */
Util::clearUserCache();

return null;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Plugins/Auth/AuthenticationCookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -933,9 +933,10 @@ public function testAuthenticate(): void
$_POST['pma_password'] = 'testPassword';

ob_start();
$this->object->authenticate();
$response = $this->object->authenticate();
$result = ob_get_clean();

self::assertNull($response);
/* Nothing should be printed */
self::assertSame('', $result);

Expand Down

0 comments on commit aa70f48

Please sign in to comment.