mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
Csrf bugfixes
This commit is contained in:
@@ -30,6 +30,23 @@ class InputCollection implements \IteratorAggregate {
|
|||||||
return $defaultValue;
|
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
|
* @param $index
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class BaseCsrfVerifier implements IMiddleware {
|
|||||||
|
|
||||||
if($request->getMethod() !== 'get' && !$this->skip($request)) {
|
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 the token is not posted, check headers for valid x-csrf-token
|
||||||
if($token === null) {
|
if($token === null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user