Commit c2e3fdf4 authored by Neslee Canil Pinto's avatar Neslee Canil Pinto Committed by japerry
Browse files

Issue #2836076 by Neslee Canil Pinto, ndf, dotist, smaz, alunyov, wundo,...

Issue #2836076 by Neslee Canil Pinto, ndf, dotist, smaz, alunyov, wundo, dmsmidt, PieterDC: Re-introduce $settings['disable_captcha'] in 8.x branch
parent da3e84ec
......@@ -83,3 +83,9 @@ MAINTAINERS
Supporting organizations:
* Chuva Inc. - https://www.drupal.org/chuva-inc
DEVELOPMENT
-------------
You can disable captcha in your local or test environment by adding the
following line to settings.php:
$settings['disable_captcha'] = TRUE;
......@@ -19,6 +19,7 @@ use Drupal\Core\Render\Element;
use Drupal\Core\Render\Markup;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\Core\Site\Settings;
/**
* Constants for CAPTCHA persistence.
......@@ -288,6 +289,22 @@ function captcha_form_alter(array &$form, FormStateInterface $form_state, $form_
'#markup' => '<div class="messages messages--warning">' . t('Most CAPTCHA methods will disable the caching of pages that contain a CAPTCHA element. Check the different implementations to know more about how it affects caching.') . '</div>',
];
}
// Disable captcha if override is set.
if (Settings::get('disable_captcha', FALSE) === TRUE) {
$override_notice = [
'#type' => 'html_tag',
'#tag' => 'strong',
'#value' => t('Captcha is currently disabled via settings.php.'),
];
if (isset($form['elements']['captcha'])) {
$form['elements']['captcha'] = $override_notice;
}
if (isset($form['captcha'])) {
$form['captcha'] = $override_notice;
}
}
}
/**
......
Supports Markdown
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