From eb2b74fdd4f6eed205b5e579613af536fae3df06 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 4 Jul 2014 08:10:49 +0200 Subject: [PATCH] Added simple antispam protection to registration --- src/Controllers/UserController.php | 5 +++++ src/Views/user/user-registration.phtml | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/Controllers/UserController.php b/src/Controllers/UserController.php index 4e5e953d..940536b5 100644 --- a/src/Controllers/UserController.php +++ b/src/Controllers/UserController.php @@ -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'); diff --git a/src/Views/user/user-registration.phtml b/src/Views/user/user-registration.phtml index f5683b07..95e10de7 100644 --- a/src/Views/user/user-registration.phtml +++ b/src/Views/user/user-registration.phtml @@ -16,6 +16,10 @@ $this->assets->setSubTitle('registration form');

Registered users can view more content,
upload files and add posts to favorites.

+
Please leave this field blank.
+
Please leave this field blank.
+
Please leave this field unchecked.
+ name = 'name';