public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
 {
     /** @link http://framework.zend.com/manual/current/en/modules/zend.authentication.intro.html */
     if (array_key_exists('Zend_Auth', $_SESSION)) {
         /** @var \Zend\Stdlib\ArrayObject $auth */
         $auth = $_SESSION['Zend_Auth'];
         if ($auth->offsetExists('storage')) {
             /** @var StdClass $storage */
             $storage = $auth->storage;
             if (property_exists($storage, 'user_id')) {
                 $this->user->login($storage->user_id, [Roles::USER]);
                 $this->user->setNamespace(UserInterface::NAMESPACES . DIRECTORY_SEPARATOR . $storage->user_id);
             }
         }
     }
     return $next($request, $response);
 }