mise à niveau pour utilisation avec flow

This commit is contained in:
2021-05-28 12:11:05 +02:00
parent 3ccfdf1c93
commit d43cc35eda
3 changed files with 20 additions and 8 deletions

View File

@ -6,6 +6,7 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Captcha validator
@ -46,6 +47,13 @@ class CaptchaValidator
*/
private $translator;
/**
* Request
*
* @var Request
*/
private $req;
/**
* @param TranslatorInterface $translator
* @param SessionInterface $session
@ -54,7 +62,7 @@ class CaptchaValidator
* @param string $bypassCode
* @param int $humanity
*/
public function __construct(TranslatorInterface $translator, SessionInterface $session, $key, $invalidMessage, $bypassCode, $humanity)
public function __construct(TranslatorInterface $translator, SessionInterface $session, $key, $invalidMessage, $bypassCode, $humanity, Request $req = null)
{
$this->translator = $translator;
$this->session = $session;
@ -62,6 +70,7 @@ class CaptchaValidator
$this->invalidMessage = $invalidMessage;
$this->bypassCode = (string)$bypassCode;
$this->humanity = $humanity;
$this->req = $req;
}
/**
@ -90,10 +99,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');
}
}
}