Commit d07f1e21 authored by Emma's avatar Emma

captcha on reset password forms

parent 6f46b256
......@@ -56,6 +56,10 @@ services:
- { name: doctrine.event_listener, event: postPersist }
- { name: kernel.event_listener, event: kernel.terminate }
Raddit\AppBundle\Form\RequestPasswordResetType:
arguments:
$bypass: "@=parameter('kernel.environment') === 'test'"
Raddit\AppBundle\Mailer\ResetPasswordMailer:
arguments:
$siteName: "%env(SITE_NAME)%"
......
......@@ -2,6 +2,7 @@
namespace Raddit\AppBundle\Form;
use Gregwar\CaptchaBundle\Type\CaptchaType;
use Raddit\AppBundle\Form\Model\RequestPasswordReset;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
......@@ -10,9 +11,24 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
final class RequestPasswordResetType extends AbstractType {
private $bypass;
/**
* @param bool $bypass enable bypass code for unit testing
*/
public function __construct(bool $bypass) {
$this->bypass = $bypass;
}
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->add('email', EmailType::class)
->add('verification', CaptchaType::class, [
'bypass_code' => $this->bypass ? 'bypass' : null,
'label' => 'label.verification',
'as_url' => true,
'reload' => true,
])
->add('submit', SubmitType::class);
}
......
......@@ -17,6 +17,7 @@ class ResetPasswordControllerTest extends WebTestCase {
$form = $crawler->selectButton('Submit')->form([
'request_password_reset[email]' => 'emma@example.com',
'request_password_reset[verification]' => 'bypass',
]);
$client->enableProfiler();
......
......@@ -229,6 +229,7 @@ label:
all: All
moderated: Moderated
recent_changes: Recent changes
verification: Verification
login_form:
log_in: Log in
......
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