ErrorHandler: Remove some form fields before serialization
This commit is contained in:
parent
b03102e3c6
commit
51a3c6eb44
|
@ -6,6 +6,7 @@ use Engelsystem\Http\Exceptions\HttpException;
|
|||
use Engelsystem\Http\Exceptions\ValidationException;
|
||||
use Engelsystem\Http\Request;
|
||||
use Engelsystem\Http\Response;
|
||||
use Illuminate\Support\Arr;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
|
@ -20,6 +21,16 @@ class ErrorHandler implements MiddlewareInterface
|
|||
/** @var string */
|
||||
protected $viewPrefix = 'errors/';
|
||||
|
||||
/**
|
||||
* A list of inputs that are not saved from form input
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $formIgnore = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param TwigLoader $loader
|
||||
*/
|
||||
|
@ -58,7 +69,7 @@ class ErrorHandler implements MiddlewareInterface
|
|||
)
|
||||
);
|
||||
|
||||
$session->set('form-data', $request->request->all());
|
||||
$session->set('form-data', Arr::except($request->request->all(), $this->formIgnore));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,11 @@ class ErrorHandlerTest extends TestCase
|
|||
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
$session->set('errors', ['validation' => ['foo' => ['validation.foo.required']]]);
|
||||
$request = Request::create('/foo/bar', 'POST', ['foo' => 'bar']);
|
||||
$request = Request::create(
|
||||
'/foo/bar',
|
||||
'POST',
|
||||
['foo' => 'bar', 'password' => 'Test123', 'password_confirmation' => 'Test1234']
|
||||
);
|
||||
$request->setSession($session);
|
||||
|
||||
/** @var Application $app */
|
||||
|
|
Loading…
Reference in New Issue