auth = $auth; } public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { // Check if user is logged in and is admin if (!$this->auth->isLoggedIn() || !$this->auth->isAdmin()) { $response = new \Slim\Psr7\Response(); return $response->withStatus(403)->withHeader('Content-Type', 'application/json'); } // Add user to request attributes $request = $request->withAttribute('user', $this->auth->getCurrentUser()); return $handler->handle($request); } }