mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-16 10:40:18 +03:00
Csrf bugfixes
This commit is contained in:
@@ -30,6 +30,23 @@ class InputCollection implements \IteratorAggregate {
|
||||
return $defaultValue;
|
||||
}
|
||||
|
||||
public function getValue($index, $defaultValue = null) {
|
||||
if(count($this->data)) {
|
||||
|
||||
if(isset($this->data[$index])) {
|
||||
return $this->data[$index]->getValue();
|
||||
}
|
||||
|
||||
foreach($this->data as $key => $value) {
|
||||
if(strtolower($index) === strtolower($key)) {
|
||||
return $value->getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $index
|
||||
* @throws \InvalidArgumentException
|
||||
|
||||
@@ -54,7 +54,7 @@ class BaseCsrfVerifier implements IMiddleware {
|
||||
|
||||
if($request->getMethod() !== 'get' && !$this->skip($request)) {
|
||||
|
||||
$token = $request->getInput()->post->findFirst(static::POST_KEY);
|
||||
$token = $request->getInput()->post->getValue(static::POST_KEY);
|
||||
|
||||
// If the token is not posted, check headers for valid x-csrf-token
|
||||
if($token === null) {
|
||||
|
||||
Reference in New Issue
Block a user