|
Revision 7902, 1.0 kB
(checked in by fabien, 5 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 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 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 |
|
|---|