diff --git a/bundle/Form/CaptchaType.php b/bundle/Form/CaptchaType.php index 43de5d84..ba858d3e 100644 --- a/bundle/Form/CaptchaType.php +++ b/bundle/Form/CaptchaType.php @@ -2,7 +2,6 @@ namespace Netgen\Bundle\InformationCollectionBundle\Form; -use Netgen\Bundle\InformationCollectionBundle\Listener\CaptchaValidationListener; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormInterface; @@ -11,11 +10,9 @@ class CaptchaType extends AbstractType { - private CaptchaValidationListener $validationListener; - public function __construct(CaptchaValidationListener $validationListener) + public function __construct() { - $this->validationListener = $validationListener; } public function buildView(FormView $view, FormInterface $form, array $options): void @@ -29,7 +26,6 @@ public function buildView(FormView $view, FormInterface $form, array $options): public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->addEventSubscriber($this->validationListener); } public function configureOptions(OptionsResolver $resolver): void diff --git a/bundle/Listener/CaptchaValidationListener.php b/bundle/Listener/CaptchaValidationListener.php deleted file mode 100644 index 1e04b8d6..00000000 --- a/bundle/Listener/CaptchaValidationListener.php +++ /dev/null @@ -1,57 +0,0 @@ -requestStack = $requestStack; - $this->captchaService = $captchaService; - $this->translator = $translator; - } - - public static function getSubscribedEvents(): array - { - return [ - FormEvents::POST_SUBMIT => 'onPostSubmit', - ]; - } - - public function onPostSubmit(FormEvent $event): void - { - $captchaValue = $event->getForm() - ->getConfig() - ->getOption('captcha_value'); - -// $request = $this->requestStack->getCurrentRequest(); - $request = Request::createFromGlobals(); - - $text = 'The captcha is invalid. Please try again.'; - - if (!$captchaValue->isValid($request)) { - $error = new FormError( - $this->translator->trans('netgen_information_collection.captcha') - ); - - $event->getForm()->addError($error); - } - } -} diff --git a/bundle/Resources/config/services.yml b/bundle/Resources/config/services.yml index b35bd036..3b9a9466 100644 --- a/bundle/Resources/config/services.yml +++ b/bundle/Resources/config/services.yml @@ -31,11 +31,3 @@ services: - '@Ibexa\Core\Helper\TranslationHelper' tags: - { name: data_collector, template: '@NetgenInformationCollection/data_collector/template.html.twig', id: 'netgen_information_collection_collector' } - - - netgen_information_collection.listener.captcha_validation: - class: Netgen\Bundle\InformationCollectionBundle\Listener\CaptchaValidationListener - arguments: - - '@request_stack' - - '@netgen_information_collection.captcha.service' - - '@translator' diff --git a/lib/Core/Service/CaptchaService.php b/lib/Core/Service/CaptchaService.php index c56be3a8..749ba703 100644 --- a/lib/Core/Service/CaptchaService.php +++ b/lib/Core/Service/CaptchaService.php @@ -54,7 +54,7 @@ public function getCaptcha(Location $location): CaptchaValue if (!empty($config['options'])) { // if (!empty($config['options']['hostname'])) { - $reCaptcha->setExpectedHostname('localhost'); +// $reCaptcha->setExpectedHostname('localhost'); // } // if (!empty($config['options']['apk_package_name'])) { // $reCaptcha->setExpectedApkPackageName($config['options']['apk_package_name']); diff --git a/lib/Resources/config/services.yml b/lib/Resources/config/services.yml index 6b19ab69..176eb37b 100644 --- a/lib/Resources/config/services.yml +++ b/lib/Resources/config/services.yml @@ -103,8 +103,6 @@ services: netgen_information_collection.form.captcha_type: class: Netgen\Bundle\InformationCollectionBundle\Form\CaptchaType - arguments: - - '@netgen_information_collection.listener.captcha_validation' tags: - { name: form.type }