diff --git a/app/composer.lock b/app/composer.lock
index f470900..c83e3a0 100644
--- a/app/composer.lock
+++ b/app/composer.lock
@@ -2743,16 +2743,16 @@
},
{
"name": "phpstan/phpdoc-parser",
- "version": "1.29.0",
+ "version": "1.29.1",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
- "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc"
+ "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/536889f2b340489d328f5ffb7b02bb6b183ddedc",
- "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc",
+ "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fcaefacf2d5c417e928405b71b400d4ce10daaf4",
+ "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4",
"shasum": ""
},
"require": {
@@ -2784,9 +2784,9 @@
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
- "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.0"
+ "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.1"
},
- "time": "2024-05-06T12:04:23+00:00"
+ "time": "2024-05-31T08:52:43+00:00"
},
{
"name": "phpunit/php-code-coverage",
diff --git a/app/src/Bootstrap.php b/app/src/Bootstrap.php
index ff42027..a0903c0 100644
--- a/app/src/Bootstrap.php
+++ b/app/src/Bootstrap.php
@@ -73,9 +73,8 @@ class Bootstrap
$containerBuilder->addDefinitions([
'config' => $config,
// more DI stuff
- 'flash' => function () {
- $messages = [];
- return new \Slim\Flash\Messages($messages);
+ 'flash' => function (ContainerInterface $container) {
+ return $container->get(SessionInterface::class)->getFlash();
},
LoggerInterface::class => function() {
$logger = new Logger();
@@ -116,10 +115,13 @@ class Bootstrap
*/
protected static function establishMiddleware(App $app): void
{
+ /** @var ContainerInterface $container */
+ $container = $app->getContainer();
+
/**
* @var Configuration
*/
- $config = $app->getContainer()->get('config');
+ $config = $container->get('config');
$app->addErrorMiddleware(true, true, true);
// Twig
@@ -132,19 +134,10 @@ class Bootstrap
->addGlobal('site_name', $config->get('site.name'));
$twig->getEnvironment()
->addGlobal('site_description', $config->get('site.description'));
+ $flash = $container->get(SessionInterface::class)->getFlash();
+ $twig->getEnvironment()
+ ->addGlobal('flash', $flash);
$app->add(TwigMiddleware::create($app, $twig));
-
- // Flash Messages
- $app->add(function ($req, $next) {
- if (session_status() !== PHP_SESSION_ACTIVE) {
- session_start();
- }
-
- /** @var $this ContainerInterface */
- $this->get('flash')->__construct($_SESSION);
-
- return $next->handle($req);
- });
}
/**
diff --git a/app/src/Controller/User/RegisterUserAction.php b/app/src/Controller/User/RegisterUserAction.php
index 4648b55..7e7c006 100644
--- a/app/src/Controller/User/RegisterUserAction.php
+++ b/app/src/Controller/User/RegisterUserAction.php
@@ -21,6 +21,7 @@ class RegisterUserAction extends Controller
$requestData = $this->request->getParsedBody();
if ($requestData['password'] !== $requestData['checked_password']) {
+ $this->session->getFlash()->add('error', "Passwords do not match.");
$response = $this->render('user/register.twig');
return $response->withStatus(400);
}
diff --git a/app/templates/layouts/skeleton.twig b/app/templates/layouts/skeleton.twig
index 0fcfb47..4bbb17f 100644
--- a/app/templates/layouts/skeleton.twig
+++ b/app/templates/layouts/skeleton.twig
@@ -11,6 +11,11 @@