From 1800e1f2e1c25f4fd265256dc10fe2d0f1eb38e4 Mon Sep 17 00:00:00 2001 From: Joey Smith Date: Thu, 1 Oct 2026 08:57:35 -0500 Subject: [PATCH] fix: read the dashboard user from the Webware\Core\UserInterface attribute IdentityMiddleware, AuthorizationMiddleware and the rest of the stack key the user on Webware\Core\UserInterface. DashboardMiddleware read Mezzio\Authentication\UserInterface, so it always saw a null user, failed closed, and the dashboard rendered no widgets. Its tests set the same wrong key, so they passed. Signed-off-by: Joey Smith --- src/Http/Middleware/DashboardMiddleware.php | 2 +- test/integration/DashboardMiddlewareIntegrationTest.php | 3 ++- test/unit/DashboardMiddlewareTest.php | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Http/Middleware/DashboardMiddleware.php b/src/Http/Middleware/DashboardMiddleware.php index 7f607f0..ccd2115 100644 --- a/src/Http/Middleware/DashboardMiddleware.php +++ b/src/Http/Middleware/DashboardMiddleware.php @@ -6,7 +6,6 @@ use Laminas\Permissions\Acl\AclInterface; use Laminas\Permissions\Acl\Role\RoleInterface; -use Mezzio\Authentication\UserInterface; use Override; use Psr\EventDispatcher\EventDispatcherInterface; use Psr\Http\Message\ResponseInterface; @@ -15,6 +14,7 @@ use Psr\Http\Server\RequestHandlerInterface; use Webware\Admin\AclWidgetFilterIterator; use Webware\Admin\Event\RegisterWidgetEvent; +use Webware\Core\UserInterface; /** * Dispatches RegisterWidgetEvent so that modules may contribute diff --git a/test/integration/DashboardMiddlewareIntegrationTest.php b/test/integration/DashboardMiddlewareIntegrationTest.php index 5c7e060..510fd26 100644 --- a/test/integration/DashboardMiddlewareIntegrationTest.php +++ b/test/integration/DashboardMiddlewareIntegrationTest.php @@ -25,6 +25,7 @@ use Webware\Admin\Event\RegisterWidgetEvent; use Webware\Admin\Http\Middleware\DashboardMiddleware; use Webware\Admin\WidgetInterface; +use Webware\Core\UserInterface as CoreUserInterface; use function array_key_exists; use function iterator_to_array; @@ -125,7 +126,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface $middleware = new DashboardMiddleware($dispatcher, $acl); $middleware->process( - $request->withAttribute(UserInterface::class, $user), + $request->withAttribute(CoreUserInterface::class, $user), $handler, ); } diff --git a/test/unit/DashboardMiddlewareTest.php b/test/unit/DashboardMiddlewareTest.php index 048db10..18b32c9 100644 --- a/test/unit/DashboardMiddlewareTest.php +++ b/test/unit/DashboardMiddlewareTest.php @@ -22,6 +22,7 @@ use Webware\Admin\Event\RegisterWidgetEvent; use Webware\Admin\Http\Middleware\DashboardMiddleware; use Webware\Admin\WidgetInterface; +use Webware\Core\UserInterface as CoreUserInterface; use function is_array; use function iterator_to_array; @@ -182,7 +183,7 @@ static function (RegisterWidgetEvent $event) use ($widgets): object { $request = new ServerRequest(); if (null !== $user) { - $request = $request->withAttribute(UserInterface::class, $user); + $request = $request->withAttribute(CoreUserInterface::class, $user); } $handler = new class($box) implements RequestHandlerInterface {