diff --git a/public/typo3conf/ext/ep_theme/Classes/Controller/AjaxFormController.php b/public/typo3conf/ext/ep_theme/Classes/Controller/AjaxFormController.php index dda85a56..0f41b0f1 100644 --- a/public/typo3conf/ext/ep_theme/Classes/Controller/AjaxFormController.php +++ b/public/typo3conf/ext/ep_theme/Classes/Controller/AjaxFormController.php @@ -64,6 +64,13 @@ class AjaxFormController extends ActionController public function processFormAction(ContactForm $contactForm) { $response['status'] = 'ok'; + + // Don't take further actions in case honeypot field is filled in + // as a spam countermeasure + if ($contactForm->getSubject()) { + return json_encode($response); + } + $this->emailService->send( $this->settings['contactFormToEmail'], $this->settings['contactFormToName'], diff --git a/public/typo3conf/ext/ep_theme/Classes/Domain/Model/Dto/ContactForm.php b/public/typo3conf/ext/ep_theme/Classes/Domain/Model/Dto/ContactForm.php index 3c046ddb..59595735 100644 --- a/public/typo3conf/ext/ep_theme/Classes/Domain/Model/Dto/ContactForm.php +++ b/public/typo3conf/ext/ep_theme/Classes/Domain/Model/Dto/ContactForm.php @@ -36,6 +36,13 @@ class ContactForm */ protected $formType = 1; + /** + * Honeypot field!! + * + * @var string + */ + protected $subject; + /** * @var string * @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty") @@ -117,6 +124,22 @@ class ContactForm $this->formType = $formType; } + /** + * @return string + */ + public function getSubject() + { + return $this->subject; + } + + /** + * @param string $subject + */ + public function setSubject($subject) + { + $this->subject = $subject; + } + /** * @return string */ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/FullForm.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/FullForm.html index f4f95bac..50586560 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/FullForm.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/FullForm.html @@ -12,6 +12,10 @@ pageUid="{settings.defaultAjaxUid}" additionalAttributes="{'v-show': '!success', '@submit.prevent': 'submitForm()'}"> +