Compare commits

..

No commits in common. "master" and "v2.1.4" have entirely different histories.

3 changed files with 9 additions and 22 deletions

View File

@ -62,8 +62,7 @@ class CaptchaType extends AbstractType
sprintf('%s%s', self::SESSION_KEY_PREFIX, $options['session_key']), sprintf('%s%s', self::SESSION_KEY_PREFIX, $options['session_key']),
$options['invalid_message'], $options['invalid_message'],
$options['bypass_code'], $options['bypass_code'],
$options['humanity'], $options['humanity']
$options['request']
); );
$builder->addEventListener(FormEvents::POST_SUBMIT, array($validator, 'validate')); $builder->addEventListener(FormEvents::POST_SUBMIT, array($validator, 'validate'));
@ -122,7 +121,6 @@ class CaptchaType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$this->options['mapped'] = false; $this->options['mapped'] = false;
$this->options['request'] = null;
$resolver->setDefaults($this->options); $resolver->setDefaults($this->options);
} }

View File

@ -8,7 +8,6 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Captcha validator. * Captcha validator.
@ -55,21 +54,13 @@ class CaptchaValidator
*/ */
private $translator; private $translator;
/**
* Request
*
* @var Request
*/
private $req;
public function __construct( public function __construct(
TranslatorInterface $translator, TranslatorInterface $translator,
SessionInterface $session, SessionInterface $session,
string $key, string $key,
string $invalidMessage, string $invalidMessage,
?string $bypassCode, ?string $bypassCode,
int $humanity, int $humanity
?Request $req
) { ) {
$this->translator = $translator; $this->translator = $translator;
$this->session = $session; $this->session = $session;
@ -77,7 +68,6 @@ class CaptchaValidator
$this->invalidMessage = $invalidMessage; $this->invalidMessage = $invalidMessage;
$this->bypassCode = $bypassCode; $this->bypassCode = $bypassCode;
$this->humanity = $humanity; $this->humanity = $humanity;
$this->req = $req;
} }
public function validate(FormEvent $event): void public function validate(FormEvent $event): void
@ -104,11 +94,10 @@ class CaptchaValidator
} }
} }
if (null == $this->req || 1 < $this->req->get('flow_registration_step')) { $this->session->remove($this->key);
$this->session->remove($this->key);
if ($this->session->has($this->key.'_fingerprint')) { if ($this->session->has($this->key.'_fingerprint')) {
$this->session->remove($this->key.'_fingerprint'); $this->session->remove($this->key.'_fingerprint');
}
} }
} }

View File

@ -1,9 +1,9 @@
{ {
"name": "cadoles/captcha", "name": "gregwar/captcha-bundle",
"type": "symfony-bundle", "type": "symfony-bundle",
"description": "Captcha bundle", "description": "Captcha bundle",
"keywords": ["symfony2", "symfony", "captcha", "bot", "visual", "code", "security", "spam"], "keywords": ["symfony2", "symfony", "captcha", "bot", "visual", "code", "security", "spam"],
"homepage": "https://github.com/Cadoles/CaptchaBundle", "homepage": "https://github.com/Gregwar/CaptchaBundle",
"license": "MIT", "license": "MIT",
"authors": [ "authors": [
{ {
@ -17,7 +17,7 @@
} }
], ],
"require": { "require": {
"php": ">=7.1.3", "php": "^7.1.3",
"ext-gd": "*", "ext-gd": "*",
"gregwar/captcha": "^1.1.9", "gregwar/captcha": "^1.1.9",
"symfony/form": "~4.0|~5.0", "symfony/form": "~4.0|~5.0",