Intégration du module ReCaptcha
This commit is contained in:
@@ -23,12 +23,16 @@
|
||||
|
||||
namespace Front\Controller;
|
||||
|
||||
use ReCaptcha\Event\ReCaptchaCheckEvent;
|
||||
use ReCaptcha\Event\ReCaptchaEvents;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Form\Definition\FrontForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class ContactController
|
||||
* @package Thelia\Controller\Front
|
||||
@@ -45,7 +49,16 @@ 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('Invalid reCAPTCHA'); }
|
||||
}
|
||||
|
||||
$this->getMailer()->sendSimpleEmailMessage(
|
||||
[ ConfigQuery::getStoreEmail() => $form->get('name')->getData() ],
|
||||
[ ConfigQuery::getStoreEmail() => ConfigQuery::getStoreName() ],
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
/*************************************************************************************/
|
||||
namespace Front\Controller;
|
||||
|
||||
use ReCaptcha\Event\ReCaptchaCheckEvent;
|
||||
use ReCaptcha\Event\ReCaptchaEvents;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Front\Front;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
@@ -47,6 +50,7 @@ use Thelia\Model\NewsletterQuery;
|
||||
use Thelia\Tools\RememberMeTrait;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
|
||||
/**
|
||||
* Class CustomerController
|
||||
* @package Thelia\Controller\Front
|
||||
@@ -161,6 +165,15 @@ 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('Invalid reCAPTCHA'); }
|
||||
}
|
||||
|
||||
$customerCreateEvent = $this->createEventInstance($form->getData());
|
||||
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent);
|
||||
|
||||
Reference in New Issue
Block a user