wantsJson()) { return response([ 'success' => false, 'message' => $e->getMessage() ], 403); } if ($exception instanceof AuthorizationException) { \Log::warning("Unauthorized Access or Action \nURL: " . $request->fullUrl() . " \nIP: " . $request->ip() . "\nForm: " . json_encode($request->all()) . "\n"); return response($exception->getMessage(), 403); } return parent::render($request, $exception); } /** * Convert an authentication exception into an unauthenticated response. * * @param \Illuminate\Http\Request $request * @param \Illuminate\Auth\AuthenticationException $exception * @return \Illuminate\Http\Response */ protected function unauthenticated($request, AuthenticationException $exception) { if ($request->expectsJson()) { return response()->json(['error' => 'Unauthenticated.'], 401); } return redirect()->guest(route('login')); } }