Implement honeypot field as spam countermeasure
This commit is contained in:
@@ -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'],
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
pageUid="{settings.defaultAjaxUid}"
|
||||
additionalAttributes="{'v-show': '!success', '@submit.prevent': 'submitForm()'}">
|
||||
<f:form.hidden property="pageUrl"/>
|
||||
<label class="block mb-4 hidden">
|
||||
<span class="text-gray-700">Betreff*</span>
|
||||
<f:form.textfield class="form-input mt-1 block w-full" property="subject"/>
|
||||
</label>
|
||||
<label class="block mb-4" :class="{ 'has-validation-error': formErrors.name }">
|
||||
<span :class="formErrors.name ? 'text-red-500' : 'text-gray-700'">Name*</span>
|
||||
<f:form.textfield class="form-input mt-1 block w-full" property="name"/>
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
pageUid="{settings.defaultAjaxUid}"
|
||||
additionalAttributes="{'v-show': '!success', '@submit.prevent': 'submitForm()'}">
|
||||
<f:form.hidden property="pageUrl"/>
|
||||
<label class="block mb-4 hidden">
|
||||
<span class="text-gray-700">Betreff*</span>
|
||||
<f:form.textfield class="form-input mt-1 block w-full" property="subject"/>
|
||||
</label>
|
||||
<label class="block mb-4" :class="{ 'has-validation-error': formErrors.gender }">
|
||||
<span :class="formErrors.gender ? 'text-red-500' : 'text-gray-700'">Gender*</span>
|
||||
<f:form.select class="form-select mt-1 block w-full" property="gender" options="{m: 'M', w: 'W', d: 'D'}"/>
|
||||
|
||||
Reference in New Issue
Block a user