Beispiel #1
0
 public function send(ResponseEvent $event)
 {
     /** @var HttpResponseEx $response */
     $response = $event->getResponse();
     if ($response->getStatusCode() === 401) {
         $user_id = $this->session->getLoggedInUserId();
         $reason = $user_id > 0 ? $this->lang->getText('Your account does not have the required authorization to view this page') : $this->lang->getText('You must be logged in to view this page');
         if ($event->isAjaxRequest()) {
             $response->setContent($reason);
         } else {
             $url = $this->response->getLoginRedirect($reason, true);
             $response->redirect($url, 302);
         }
     }
     if (!headers_sent()) {
         foreach ($response->getHeaders() as $header) {
             header($header, false);
         }
     }
     echo $response->getContent() ?? sprintf("Error code: %d", $response->getStatusCode());
 }