Skip to content

Commit

Permalink
Allow captcha demo of flood limit
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Aug 16, 2023
1 parent 4d502af commit 1ca3e89
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions plugins/Sandbox/src/Controller/CaptchasController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Sandbox\Controller;

use Cake\Core\Configure;
use Tools\Form\ContactForm;

/**
Expand Down Expand Up @@ -35,6 +36,10 @@ public function index() {
* @return \Cake\Http\Response|null|void
*/
public function math() {
if ($this->request->getQuery('max')) {
Configure::write('Captcha.maxPerUser', (int)$this->request->getQuery('max'));
}

$animal = $this->Animals->newEmptyEntity();
if ($this->request->is('post')) {
$animal = $this->Animals->patchEntity($animal, $this->request->getData());
Expand Down
7 changes: 6 additions & 1 deletion plugins/Sandbox/templates/Captchas/math.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
<?= $this->Form->end() ?>

<br><br>
<p>Note: There is also a 2 second min-time by default! If you (as bot) do it too fast, this is also punished.</p>
<p>Note:</p>
<ul>
<li>There is also a 2 second min-time by default! If you (as bot) do it too fast, this is also invalidated.</li>
<li>The `Captcha.maxPerUser` value sets a flood limit (currently <?php echo h((string)$this->Configure->read('Captcha.maxPerUser') ?: 1000); ?>) to avoid such attempts.</li>
</ul>
<p>For testing purposes you can adjust the `maxPerUser` value here using query string `?max=...`: <?php echo $this->Html->link('Adjust to 10', ['action' => 'math', '?' => ['max' => '10']])?></p>

<h3>Key Goals</h3>
<ul>
Expand Down

0 comments on commit 1ca3e89

Please sign in to comment.