- 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>
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace ROITheme\Shared\Domain\Contracts;
|
|
|
|
use ROITheme\Shared\Domain\Entities\RecaptchaResult;
|
|
|
|
/**
|
|
* RecaptchaValidatorInterface - Contrato para validacion de reCAPTCHA
|
|
*
|
|
* RESPONSABILIDAD: Definir el contrato para validar tokens de reCAPTCHA v3
|
|
* con la API de Google.
|
|
*
|
|
* PRINCIPIOS:
|
|
* - Interface Segregation: Una sola responsabilidad - validar tokens
|
|
* - Dependency Inversion: Depender de abstraccion, no de implementacion
|
|
*
|
|
* USO:
|
|
* ```php
|
|
* final class GoogleRecaptchaValidator implements RecaptchaValidatorInterface
|
|
* {
|
|
* public function validate(string $token, string $action, string $secretKey): RecaptchaResult
|
|
* {
|
|
* // Llamar a API de Google y retornar resultado
|
|
* }
|
|
* }
|
|
* ```
|
|
*
|
|
* @package ROITheme\Shared\Domain\Contracts
|
|
*/
|
|
interface RecaptchaValidatorInterface
|
|
{
|
|
/**
|
|
* Validar un token de reCAPTCHA v3 con la API de Google
|
|
*
|
|
* @param string $token Token generado por reCAPTCHA en frontend
|
|
* @param string $action Nombre de la accion (ej: 'newsletter_submit', 'contact_submit')
|
|
* @param string $secretKey Clave secreta de reCAPTCHA
|
|
* @return RecaptchaResult Resultado de la validacion con score y estado
|
|
*/
|
|
public function validate(string $token, string $action, string $secretKey): RecaptchaResult;
|
|
}
|