Beispiel #1
0
 public function isloggedinAction()
 {
     if (trim($_SERVER['REQUEST_METHOD']) === "GET") {
         if ($this->session->isLocked()) {
             $this->session->unLock();
         }
         session_write_close();
     }
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $res = "0";
     header('Access-Control-Allow-Origin: *');
     if ($this->session && isset($this->session->developsession) && $this->session->developsession === true) {
         if ($this->session->userid) {
             $res = "1";
         }
     }
     if ($res === "0") {
         $source = SamlAuth::isAuthenticated();
     }
     if ($source !== false) {
         $res = "1";
         if (isset($_GET['profile']) && $_GET['profile'] === 'attributes' && $this->isAllowedProfileDataDomain()) {
             header('Content-type: application/json');
             $attrs = $source->getAttributes();
             if ($attrs && count($attrs) > 0) {
                 $sourceIdentifier = false;
                 $uid = false;
                 $userAccount = false;
                 try {
                     if (isset($attrs['idp:sourceIdentifier']) && count($attrs['idp:sourceIdentifier']) === 1) {
                         $sourceIdentifier = $attrs['idp:sourceIdentifier'][0];
                         $sourceIdentifier = str_replace('-sp', '', $sourceIdentifier);
                     }
                     if (isset($attrs['idp:uid']) && count($attrs['idp:uid']) === 1) {
                         $uid = $attrs['idp:uid'][0];
                     }
                     if ($sourceIdentifier && $uid) {
                         $userAccount = SamlAuth::getUserAccount($uid, $sourceIdentifier);
                     }
                     if ($userAccount) {
                         $attrs['entitlements'] = array('vo' => array('memberships' => VoAdmin::getUserMembership($userAccount->researcherid)));
                     }
                 } catch (Exception $ex) {
                 }
             }
             echo json_encode($attrs);
             return;
         }
     }
     echo $res;
 }