generated from liutk/owl-admin-base
AuthenticationException
parent
7abf180f3b
commit
f35a0e0e6d
|
|
@ -7,6 +7,7 @@ use Throwable;
|
||||||
use Illuminate\Http\{Request, Response};
|
use Illuminate\Http\{Request, Response};
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Slowlyo\OwlAdmin\Exceptions\AdminException;
|
use Slowlyo\OwlAdmin\Exceptions\AdminException;
|
||||||
|
use Illuminate\Auth\AuthenticationException;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
|
|
@ -49,4 +50,11 @@ class Handler extends ExceptionHandler
|
||||||
'errors' => $exception->errors(),
|
'errors' => $exception->errors(),
|
||||||
], $exception->status);
|
], $exception->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function unauthenticated($request, AuthenticationException $exception)
|
||||||
|
{
|
||||||
|
return $this->shouldReturnJson($request, $exception)
|
||||||
|
? response()->json(['code' => Response::HTTP_UNAUTHORIZED, 'message' => $exception->getMessage()], 401)
|
||||||
|
: redirect()->guest($exception->redirectTo() ?? route('login'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue