mise à niveau pour utilisation avec flow
This commit is contained in:
parent
3ccfdf1c93
commit
d43cc35eda
@ -70,7 +70,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']
|
||||||
);
|
);
|
||||||
$event = \Symfony\Component\HttpKernel\Kernel::VERSION >= 2.3 ? FormEvents::POST_SUBMIT : FormEvents::POST_BIND;
|
$event = \Symfony\Component\HttpKernel\Kernel::VERSION >= 2.3 ? FormEvents::POST_SUBMIT : FormEvents::POST_BIND;
|
||||||
$builder->addEventListener($event, array($validator, 'validate'));
|
$builder->addEventListener($event, array($validator, 'validate'));
|
||||||
@ -129,6 +130,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,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\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Captcha validator
|
* Captcha validator
|
||||||
@ -46,6 +47,13 @@ class CaptchaValidator
|
|||||||
*/
|
*/
|
||||||
private $translator;
|
private $translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request
|
||||||
|
*
|
||||||
|
* @var Request
|
||||||
|
*/
|
||||||
|
private $req;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TranslatorInterface $translator
|
* @param TranslatorInterface $translator
|
||||||
* @param SessionInterface $session
|
* @param SessionInterface $session
|
||||||
@ -54,7 +62,7 @@ class CaptchaValidator
|
|||||||
* @param string $bypassCode
|
* @param string $bypassCode
|
||||||
* @param int $humanity
|
* @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->translator = $translator;
|
||||||
$this->session = $session;
|
$this->session = $session;
|
||||||
@ -62,6 +70,7 @@ class CaptchaValidator
|
|||||||
$this->invalidMessage = $invalidMessage;
|
$this->invalidMessage = $invalidMessage;
|
||||||
$this->bypassCode = (string)$bypassCode;
|
$this->bypassCode = (string)$bypassCode;
|
||||||
$this->humanity = $humanity;
|
$this->humanity = $humanity;
|
||||||
|
$this->req = $req;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,12 +99,13 @@ 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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the expected CAPTCHA code
|
* Retrieve the expected CAPTCHA code
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "gregwar/captcha-bundle",
|
"name": "cadoles/captcha",
|
||||||
"type": "captcha-bundle",
|
"type": "captcha-bundle",
|
||||||
"description": "Captcha bundle",
|
"description": "Captcha bundle",
|
||||||
"keywords": ["symfony2", "captcha", "bot", "visual", "code", "security", "spam"],
|
"keywords": ["symfony2", "captcha", "bot", "visual", "code", "security", "spam"],
|
||||||
"homepage": "https://github.com/Gregwar/CaptchaBundle",
|
"homepage": "https://github.com/Cadoles/CaptchaBundle",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user