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:
bootstrap: true
spam: true
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() {
}
}
/**
* Implements hook_update_N().
*/
/**
* Enables OFIS module.
*/
......@@ -71,3 +75,11 @@ function uw_sites_all_update_8101(&$sandbox) {
function uw_sites_all_update_8102(&$sandbox) {
\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 @@
* Workbench module file.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\menu_link_content\Entity\MenuLinkContent;
......@@ -126,3 +127,18 @@ function uw_sites_all_update_projects_alter(&$projects) {
$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