1. sfValidatorCSRFToken.class.php
  2. /** * sfValidatorCSRFToken checks that the token is valid. * * @package symfony * @subpackage validator * @author Fabien Potencier * @version SVN: $Id: sfValidatorCSRFToken.class.php 7902 2008-03-15 13:17:33Z fabien $ */
  3. class sfValidatorCSRFToken extends sfValidatorBase
  4. {
  5. /**
  6. * @see sfValidatorBase
  7. */
  8. protected function configure($options = array(), $messages = array())
  9. {
  10. $this->addRequiredOption('token');
  11. $this->setOption('required', true);
  12. $this->addMessage('csrf_attack', 'CSRF attack detected.');
  13. }
  14. /**
  15. * @see sfValidatorBase
  16. */
  17. protected function doClean($value)
  18. {
  19. if ($value != $this->getOption('token'))
  20. {
  21. throw new sfValidatorError($this, 'csrf_attack');
  22. }
  23. return $value;
  24. }
  25. }

Debug toolbar