Example #1
0
 public function disconnectaccountAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     if ($_SERVER['REQUEST_METHOD'] !== 'POST' || isset($this->session->userid) === false || is_numeric($this->session->userid) === false || intval($this->session->userid) <= 0 || isset($_POST["id"]) === false || is_numeric($_POST["id"]) === false || intval($_POST["id"]) <= 0) {
         header("HTTP/1.0 404 Not Found");
         return;
     }
     $result = array();
     $id = intval($_POST["id"]);
     $uaccs = SamlAuth::getUserAccountsByUser($this->session->userid);
     if (count($uaccs) === 1) {
         $result = array("error" => "Cannot remove last user account");
     } else {
         if (count($uaccs) > 1) {
             for ($i = 0; $i < count($uaccs); $i += 1) {
                 $ua = $uaccs[$i];
                 if ($ua->id === $id) {
                     AccountConnect::disconnectAccount($this->session, $ua);
                     break;
                 }
             }
             $result = SamlAuth::getUserAccountsByUser($this->session->userid, true);
             $this->session->currentUserAccounts = $result;
         }
     }
     header('Content-type: application/json');
     echo json_encode($result);
 }