1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

Simplify ApiAuthException control flow

Remove unnecessary UnauthorizedException
and make ApiAuthException compatible with HttpExceptionInterface.

Move the creation of a rsponse for the exception
from ApiAuthenticate middleware into the application exception handler.
This commit is contained in:
Thomas Kuschan
2023-06-14 11:52:22 +02:00
parent ec775aec02
commit 74097bd47c
3 changed files with 24 additions and 37 deletions

View File

@@ -2,6 +2,25 @@
namespace BookStack\Exceptions;
class ApiAuthException extends UnauthorizedException
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
class ApiAuthException extends \Exception implements HttpExceptionInterface
{
protected int $status;
public function __construct(string $message, int $statusCode = 401)
{
$this->status = $statusCode;
parent::__construct($message, $statusCode);
}
public function getStatusCode(): int
{
return $this->status;
}
public function getHeaders(): array
{
return [];
}
}