Commit 133ed31e authored by Kevin Paxman's avatar Kevin Paxman
Browse files

Merge branch 'feature/ISTWCMS-4881-lkmorlan-enable-spam-prevention' into '1.0.x'

ISTWCMS-4881: Protect Webforms from spam

See merge request !45
parents 7af8fe39 0100dafc
...@@ -221,4 +221,8 @@ requirements: ...@@ -221,4 +221,8 @@ requirements:
bootstrap: true bootstrap: true
spam: true spam: true
langcode: en langcode: en
third_party_settings: { } third_party_settings:
captcha:
replace_administration_mode: false
honeypot:
honeypot: true
...@@ -58,6 +58,10 @@ function uw_sites_all_uninstall() { ...@@ -58,6 +58,10 @@ function uw_sites_all_uninstall() {
} }
} }
/**
* Implements hook_update_N().
*/
/** /**
* Enables OFIS module. * Enables OFIS module.
*/ */
...@@ -71,3 +75,11 @@ function uw_sites_all_update_8101(&$sandbox) { ...@@ -71,3 +75,11 @@ function uw_sites_all_update_8101(&$sandbox) {
function uw_sites_all_update_8102(&$sandbox) { function uw_sites_all_update_8102(&$sandbox) {
\Drupal::service('module_installer')->install(['uw_ckeditor_plugins']); \Drupal::service('module_installer')->install(['uw_ckeditor_plugins']);
} }
/**
* Protect all Webforms with Honeypot.
*/
function uw_sites_all_update_8103() {
$config = \Drupal::service('config.factory')->getEditable('webform.settings');
$config->set('third_party_settings.honeypot.honeypot', TRUE)->save();
}
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* Workbench module file. * Workbench module file.
*/ */
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\menu_link_content\Entity\MenuLinkContent; use Drupal\menu_link_content\Entity\MenuLinkContent;
...@@ -126,3 +127,18 @@ function uw_sites_all_update_projects_alter(&$projects) { ...@@ -126,3 +127,18 @@ function uw_sites_all_update_projects_alter(&$projects) {
$project['info']['version'] = preg_replace('/-uw_wcms\d*$/', '', $project['info']['version']); $project['info']['version'] = preg_replace('/-uw_wcms\d*$/', '', $project['info']['version']);
} }
} }
/**
* Implements hook_ENTITY_TYPE_presave().
*/
function uw_sites_all_webform_presave(EntityInterface $webform): void {
// Add a Webform CAPTCHA component to each newly-created Webform.
if ($webform->isNew()) {
$elements = [
'captcha' => [
'#type' => 'captcha',
],
];
$webform->setElements($elements);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment