Development

/branches/1.3/lib/validator/sfValidatorCSRFToken.class.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/validator/sfValidatorCSRFToken.class.php

Revision 7902, 1.0 kB (checked in by fabien, 6 years ago)

rename sfValidatorBase to sfValidator in sfCompat10Plugin and renamed the new sfValidator class to sfValidatorBase (closes #3103)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * sfValidatorCSRFToken checks that the token is valid.
13  *
14  * @package    symfony
15  * @subpackage validator
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfValidatorCSRFToken extends sfValidatorBase
20 {
21   /**
22    * @see sfValidatorBase
23    */
24   protected function configure($options = array(), $messages = array())
25   {
26     $this->addRequiredOption('token');
27
28     $this->setOption('required', true);
29
30     $this->addMessage('csrf_attack', 'CSRF attack detected.');
31   }
32
33   /**
34    * @see sfValidatorBase
35    */
36   protected function doClean($value)
37   {
38     if ($value != $this->getOption('token'))
39     {
40       throw new sfValidatorError($this, 'csrf_attack');
41     }
42
43     return $value;
44   }
45 }
46
Note: See TracBrowser for help on using the browser.