Skip to content

Commit

Permalink
Use original error code and rename exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Butcher committed Aug 29, 2023
1 parent ecd5d9e commit 2b6ad49
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Symfony\Component\HttpKernel\Exception\HttpException;

class UnauthorizedException extends HttpException
class ForbiddenException extends HttpException
{
//
}
4 changes: 2 additions & 2 deletions src/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Laravel\Horizon\Http\Middleware;

use Laravel\Horizon\Exceptions\UnauthorizedException;
use Laravel\Horizon\Exceptions\ForbiddenException;
use Laravel\Horizon\Horizon;

class Authenticate
Expand All @@ -17,7 +17,7 @@ class Authenticate
public function handle($request, $next)
{
if (! Horizon::check($request)) {
throw new UnauthorizedException(401);
throw new ForbiddenException(403);
}

return $next($request);
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Laravel\Horizon\Tests\Feature;

use Laravel\Horizon\Exceptions\UnauthorizedException;
use Laravel\Horizon\Exceptions\ForbiddenException;
use Laravel\Horizon\Horizon;
use Laravel\Horizon\Http\Middleware\Authenticate;
use Laravel\Horizon\Tests\IntegrationTest;
Expand Down Expand Up @@ -43,7 +43,7 @@ function ($value) {

public function test_authentication_middleware_throws_on_failure()
{
$this->expectException(UnauthorizedException::class);
$this->expectException(ForbiddenException::class);

Horizon::auth(function () {
return false;
Expand Down

0 comments on commit 2b6ad49

Please sign in to comment.