Added simple antispam protection to registration

This commit is contained in:
Marcin Kurczewski 2014-07-04 08:10:49 +02:00
parent 6543dcc8f9
commit eb2b74fdd4
2 changed files with 9 additions and 0 deletions

View file

@ -202,6 +202,11 @@ class UserController extends AbstractController
{
$this->interceptErrors(function()
{
$honeypot = ['username', 'mail', 'agree'];
foreach ($honeypot as $f)
if (InputHelper::get($f))
throw new SimpleException('Human verification failed');
if (InputHelper::get('password1') != InputHelper::get('password2'))
throw new SimpleException('Specified passwords must be the same');

View file

@ -16,6 +16,10 @@ $this->assets->setSubTitle('registration form');
<p>Registered users can view more content,<br/>upload files and add posts to favorites.</p>
<div style="display:none"><input name="username"/> Please leave this field blank.</div>
<div style="display:none"><input name="mail"/> Please leave this field blank.</div>
<div style="display:none"><input type="checkbox" name="agree"/> Please leave this field unchecked.</div>
<?php
$context = new StdClass;
$context->name = 'name';