123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace App\Exceptions;
- use Exception;
- use Illuminate\Auth\AuthenticationException;
- use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
- class Handler extends ExceptionHandler
- {
-
- protected $dontReport = [
- ResponseException::class
- ];
-
- protected $dontFlash = [
- 'password',
- 'password_confirmation',
- ];
-
- public function report(Exception $exception)
- {
- parent::report($exception);
- }
-
- public function render($request, Exception $exception)
- {
- return parent::render($request, $exception);
- }
-
- protected function unauthenticated($request, AuthenticationException $exception)
- {
- $route_name='login';
- if (is_mobile_route()) {
- $route_name='mobile.login';
- } elseif (is_pad_route()) {
- $route_name='hardware.pad.login';
- } elseif (is_statistics_route()) {
- $route_name='statistics.login';
- }
- return $request->expectsJson()
- ? response()->json(['message' => $exception->getMessage()], 401)
- : redirect()->guest(route($route_name));
- }
- }
|