Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
wpetit | 5778c54ae0 | |
Benjamin Gaudé | 9b65966d27 | |
Benjamin Gaudé | 633e30ae47 | |
Grégoire Passault | 2f96c759ab | |
Gemorroj | 2769e4791a |
|
@ -62,7 +62,8 @@ class CaptchaType extends AbstractType
|
|||
sprintf('%s%s', self::SESSION_KEY_PREFIX, $options['session_key']),
|
||||
$options['invalid_message'],
|
||||
$options['bypass_code'],
|
||||
$options['humanity']
|
||||
$options['humanity'],
|
||||
$options['request']
|
||||
);
|
||||
|
||||
$builder->addEventListener(FormEvents::POST_SUBMIT, array($validator, 'validate'));
|
||||
|
@ -121,6 +122,7 @@ class CaptchaType extends AbstractType
|
|||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$this->options['mapped'] = false;
|
||||
$this->options['request'] = null;
|
||||
$resolver->setDefaults($this->options);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
|||
use Symfony\Component\Form\FormError;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Captcha validator.
|
||||
|
@ -54,13 +55,21 @@ class CaptchaValidator
|
|||
*/
|
||||
private $translator;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
private $req;
|
||||
|
||||
public function __construct(
|
||||
TranslatorInterface $translator,
|
||||
SessionInterface $session,
|
||||
string $key,
|
||||
string $invalidMessage,
|
||||
?string $bypassCode,
|
||||
int $humanity
|
||||
int $humanity,
|
||||
?Request $req
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
$this->session = $session;
|
||||
|
@ -68,6 +77,7 @@ class CaptchaValidator
|
|||
$this->invalidMessage = $invalidMessage;
|
||||
$this->bypassCode = $bypassCode;
|
||||
$this->humanity = $humanity;
|
||||
$this->req = $req;
|
||||
}
|
||||
|
||||
public function validate(FormEvent $event): void
|
||||
|
@ -94,10 +104,11 @@ class CaptchaValidator
|
|||
}
|
||||
}
|
||||
|
||||
$this->session->remove($this->key);
|
||||
|
||||
if ($this->session->has($this->key.'_fingerprint')) {
|
||||
$this->session->remove($this->key.'_fingerprint');
|
||||
if (null == $this->req || 1 < $this->req->get('flow_registration_step')) {
|
||||
$this->session->remove($this->key);
|
||||
if ($this->session->has($this->key.'_fingerprint')) {
|
||||
$this->session->remove($this->key.'_fingerprint');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"name": "gregwar/captcha-bundle",
|
||||
"name": "cadoles/captcha",
|
||||
"type": "symfony-bundle",
|
||||
"description": "Captcha bundle",
|
||||
"keywords": ["symfony2", "symfony", "captcha", "bot", "visual", "code", "security", "spam"],
|
||||
"homepage": "https://github.com/Gregwar/CaptchaBundle",
|
||||
"homepage": "https://github.com/Cadoles/CaptchaBundle",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
|
@ -17,7 +17,7 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"php": ">=7.1.3",
|
||||
"ext-gd": "*",
|
||||
"gregwar/captcha": "^1.1.9",
|
||||
"symfony/form": "~4.0|~5.0",
|
||||
|
|
Loading…
Reference in New Issue