Sentry + Nuxt upgrade & (#738)
Implement Enhanced Validation Logging in UserFormRequest - Added a `failedValidation` method in `UserFormRequest` to log validation errors, including request data and user information, to the combined log channel and Slack. - Updated `nuxt.config.ts` to integrate the latest Sentry module and adjusted configurations for improved error tracking. - Refactored the `FeatureBase.vue` component to include error handling during user setup. - Removed the deprecated Sentry plugin and replaced it with the new Sentry Nuxt integration for better performance and maintainability. These changes aim to enhance error tracking and improve the overall robustness of form validation and user experience.
This commit is contained in:
@@ -5,6 +5,9 @@ namespace App\Http\Requests;
|
||||
use App\Http\Requests\Workspace\CustomDomainRequest;
|
||||
use App\Models\Forms\Form;
|
||||
use App\Rules\FormPropertyLogicRule;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
@@ -30,6 +33,37 @@ abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest
|
||||
$this->merge($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a failed validation attempt.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Validation\Validator $validator
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
protected function failedValidation(Validator $validator)
|
||||
{
|
||||
// Log validation errors to default log and Slack
|
||||
$errors = $validator->errors()->toArray();
|
||||
$requestData = $this->except(['password']); // Exclude sensitive data
|
||||
|
||||
$logData = [
|
||||
'errors' => $errors,
|
||||
'request_data' => $requestData,
|
||||
'ip' => request()->ip(),
|
||||
'user_agent' => request()->userAgent(),
|
||||
'route' => request()->route()->getName() ?? request()->path()
|
||||
];
|
||||
|
||||
// Log to both default channel and Slack
|
||||
Log::channel('combined')->warning(
|
||||
'Frontend validation bypass detected in form submission',
|
||||
$logData
|
||||
);
|
||||
|
||||
throw new ValidationException($validator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user