paddle-logging verbessert
This commit is contained in:
@@ -10,7 +10,9 @@ use Illuminate\Http\Client\ConnectionException as HttpClientConnectionException;
|
||||
use Illuminate\Queue\InvalidQueueException;
|
||||
use Illuminate\Queue\MaxAttemptsExceededException;
|
||||
use Illuminate\Routing\Exceptions\InvalidSignatureException;
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use League\Flysystem\FilesystemException;
|
||||
use PDOException;
|
||||
@@ -53,6 +55,10 @@ class Handler extends ExceptionHandler
|
||||
|
||||
public function render($request, Throwable $e)
|
||||
{
|
||||
if ($e instanceof TokenMismatchException) {
|
||||
$this->logCsrfMismatch($request);
|
||||
}
|
||||
|
||||
if ($request->expectsJson()) {
|
||||
if ($e instanceof ValidationException) {
|
||||
return ApiError::response(
|
||||
@@ -244,4 +250,19 @@ class Handler extends ExceptionHandler
|
||||
|
||||
return $throwable instanceof $className;
|
||||
}
|
||||
|
||||
private function logCsrfMismatch($request): void
|
||||
{
|
||||
if (! app()->environment('development')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log::warning('[CSRF] Token mismatch', [
|
||||
'method' => $request->method(),
|
||||
'path' => $request->path(),
|
||||
'full_url' => $request->fullUrl(),
|
||||
'ip' => $request->ip(),
|
||||
'user_id' => optional($request->user())->getAuthIdentifier(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user