auth = $auth; } public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { // Check if user is logged in if (!$this->auth->isLoggedIn()) { $response = new \Slim\Psr7\Response(); return $response->withStatus(302)->withHeader('Location', '/login'); } // Add user to request attributes $request = $request->withAttribute('user', $this->auth->getCurrentUser()); return $handler->handle($request); } }