Fixing session key, removing valid_keys which was painful to transport
the whitelist in the session (see #36)
This commit is contained in:
@ -25,6 +25,12 @@ class CaptchaType extends AbstractType
|
||||
*/
|
||||
protected $session;
|
||||
|
||||
/**
|
||||
* The session key
|
||||
* @var string
|
||||
*/
|
||||
protected $key = null;
|
||||
|
||||
/**
|
||||
* @var \Gregwar\CaptchaBundle\Generator\CaptchaGenerator
|
||||
*/
|
||||
@ -54,9 +60,11 @@ class CaptchaType extends AbstractType
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$this->key = 'gcb_'.$builder->getForm()->getName();
|
||||
|
||||
$validator = new CaptchaValidator(
|
||||
$this->session,
|
||||
$builder->getForm()->getName(),
|
||||
$this->key,
|
||||
$options['invalid_message'],
|
||||
$options['bypass_code']
|
||||
);
|
||||
@ -74,7 +82,7 @@ class CaptchaType extends AbstractType
|
||||
$view->vars = array_merge($view->vars, array(
|
||||
'captcha_width' => $options['width'],
|
||||
'captcha_height' => $options['height'],
|
||||
'captcha_code' => $this->generator->getCaptchaCode($form->getName(), $options),
|
||||
'captcha_code' => $this->generator->getCaptchaCode($this->key, $options),
|
||||
'value' => '',
|
||||
));
|
||||
}
|
||||
@ -103,4 +111,4 @@ class CaptchaType extends AbstractType
|
||||
{
|
||||
return 'captcha';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user