🐛 修复 BUG
This commit is contained in:
@@ -2,11 +2,15 @@
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use App\Http\Api;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
use Api;
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
@@ -38,4 +42,11 @@ class Handler extends ExceptionHandler
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
protected function unauthenticated($request, AuthenticationException $exception)
|
||||
{
|
||||
return $this->shouldReturnJson($request, $exception)
|
||||
? $this->error($exception->getMessage())->setStatusCode(401)
|
||||
: redirect()->guest($exception->redirectTo() ?? route('login'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user