On déplace la gestion du contrôle du Captcha dans un controller spécifique --> c'est plus propre (merci Franck :-)

This commit is contained in:
2019-12-03 16:46:46 +01:00
parent 5d3943cd4b
commit 66758f160a
5 changed files with 45 additions and 21 deletions

View File

@@ -50,15 +50,6 @@ class ContactController extends BaseFrontController
try {
$form = $this->validateForm($contactForm);
$checkModule = ModuleQuery::create()
->findOneByCode('ReCaptcha');
if($checkModule && $checkModule->getActivate()){
$checkCaptchaEvent = new ReCaptchaCheckEvent();
$this->dispatch(ReCaptchaEvents::CHECK_CAPTCHA_EVENT, $checkCaptchaEvent);
if ($checkCaptchaEvent->isHuman() == false) { throw new FormValidationException('Veuillez confirmer que vous n\'êtes pas un robot.'); }
}
$this->getMailer()->sendSimpleEmailMessage(
[ ConfigQuery::getStoreEmail() => $form->get('name')->getData() ],
[ ConfigQuery::getStoreEmail() => ConfigQuery::getStoreName() ],

View File

@@ -164,18 +164,7 @@ class CustomerController extends BaseFrontController
try {
$form = $this->validateForm($customerCreation, "post");
$checkModule = ModuleQuery::create()
->findOneByCode('ReCaptcha');
if($checkModule && $checkModule->getActivate()){
$checkCaptchaEvent = new ReCaptchaCheckEvent();
$this->dispatch(ReCaptchaEvents::CHECK_CAPTCHA_EVENT, $checkCaptchaEvent);
if ($checkCaptchaEvent->isHuman() == false) { throw new \Exception('Veuillez confirmer que vous n\'êtes pas un robot.'); }
}
$customerCreateEvent = $this->createEventInstance($form->getData());
$this->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent);
$newCustomer = $customerCreateEvent->getCustomer();