mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
CsrfCounterMeasure: Save calls to setRequired()' and
setIgnore()'
This commit is contained in:
parent
8106fe4f79
commit
9db76bf371
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Form\Element;
|
namespace Icinga\Web\Form\Element;
|
||||||
|
|
||||||
use Zend_Form_Element_Xhtml;
|
|
||||||
use Icinga\Web\Session;
|
use Icinga\Web\Session;
|
||||||
|
use Icinga\Web\Form\FormElement;
|
||||||
use Icinga\Web\Form\InvalidCSRFTokenException;
|
use Icinga\Web\Form\InvalidCSRFTokenException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,7 +13,7 @@ use Icinga\Web\Form\InvalidCSRFTokenException;
|
|||||||
*
|
*
|
||||||
* You must not set a value to successfully use this element, just give it a name and you're good to go.
|
* You must not set a value to successfully use this element, just give it a name and you're good to go.
|
||||||
*/
|
*/
|
||||||
class CsrfCounterMeasure extends Zend_Form_Element_Xhtml
|
class CsrfCounterMeasure extends FormElement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Default form view helper to use for rendering
|
* Default form view helper to use for rendering
|
||||||
@ -22,14 +22,26 @@ class CsrfCounterMeasure extends Zend_Form_Element_Xhtml
|
|||||||
*/
|
*/
|
||||||
public $helper = 'formHidden';
|
public $helper = 'formHidden';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counter measure element is required
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $_ignore = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ignore element when retrieving values at form level
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $_required = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize this form element
|
* Initialize this form element
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->setRequired(true); // Not requiring this element would not make any sense
|
$this->addDecorator('ViewHelper');
|
||||||
$this->setIgnore(true); // We do not want this element's value being retrieved by Form::getValues()
|
|
||||||
$this->setDecorators(array('ViewHelper'));
|
|
||||||
$this->setValue($this->generateCsrfToken());
|
$this->setValue($this->generateCsrfToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user