Add flow registration validation support
This commit is contained in:
parent
2f96c759ab
commit
633e30ae47
|
@ -62,7 +62,8 @@ 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'));
|
||||||
|
@ -121,6 +122,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ 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.
|
||||||
|
@ -54,13 +55,21 @@ 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;
|
||||||
|
@ -94,10 +103,11 @@ class CaptchaValidator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->session->remove($this->key);
|
if (null == $this->req || 1 < $this->req->get('flow_registration_step')) {
|
||||||
|
$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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue