feat(api): implement recaptcha v3 anti-spam protection

- Add RecaptchaValidatorInterface and RecaptchaResult entity in Domain
- Create RecaptchaValidationService in Application layer
- Implement GoogleRecaptchaValidator for API integration
- Add recaptcha-settings schema and admin FormBuilder
- Integrate reCAPTCHA validation in NewsletterAjaxHandler
- Integrate reCAPTCHA validation in ContactFormAjaxHandler
- Update FooterRenderer and ContactFormRenderer with reCAPTCHA scripts
- Configure DIContainer with RecaptchaValidationService injection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
FrankZamora
2026-01-08 17:01:46 -06:00
parent 0f6387ab46
commit d135ec8a41
16 changed files with 1299 additions and 37 deletions

View File

@@ -143,15 +143,20 @@ try {
);
$adminAjaxHandler->register();
// Obtener servicio de validacion reCAPTCHA para inyectar en handlers
$recaptchaService = $container->getRecaptchaValidationService();
// Crear y registrar el handler AJAX para el Contact Form (público)
$contactFormAjaxHandler = new \ROITheme\Public\ContactForm\Infrastructure\Api\WordPress\ContactFormAjaxHandler(
$container->getComponentSettingsRepository()
$container->getComponentSettingsRepository(),
$recaptchaService
);
$contactFormAjaxHandler->register();
// Crear y registrar el handler AJAX para Newsletter (público)
$newsletterAjaxHandler = new \ROITheme\Public\Footer\Infrastructure\Api\WordPress\NewsletterAjaxHandler(
$container->getComponentSettingsRepository()
$container->getComponentSettingsRepository(),
$recaptchaService
);
$newsletterAjaxHandler->register();
@@ -295,9 +300,10 @@ add_action('wp_footer', function() use ($container) {
visibility: \ROITheme\Shared\Domain\ValueObjects\ComponentVisibility::allDevices()
);
// Crear renderer y renderizar modal
// Crear renderer y renderizar modal (con soporte reCAPTCHA)
$cssGenerator = new \ROITheme\Shared\Infrastructure\Services\CSSGeneratorService();
$renderer = new \ROITheme\Public\ContactForm\Infrastructure\Ui\ContactFormRenderer($cssGenerator);
$recaptchaService = $container->getRecaptchaValidationService();
$renderer = new \ROITheme\Public\ContactForm\Infrastructure\Ui\ContactFormRenderer($cssGenerator, $recaptchaService);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $renderer->renderModal($component);