🐛 修复 BUG

This commit is contained in:
Wisp X
2022-02-16 15:52:00 +08:00
parent 4c95073963
commit 93f7e111ba
2 changed files with 12 additions and 1 deletions
+11
View File
@@ -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'));
}
}