예제 #1
0
 public function loginUser()
 {
     $this->_user = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\User')->findOneBy(array('uniqueName' => 'previewuser', 'isActive' => true));
     $this->_controller->getStore()->expire();
     $this->_controller->getStore()->touchAuthentication();
     $this->_controller->getStore()->set(self::SESSION_VAR_ID, $this->_user->getId());
 }
예제 #2
0
 /**
  * @SuppressWarnings(PHPMD.ExitExpression)
  * @throws \Jazzee\Exception
  */
 public function loginUser()
 {
     $config = $this->_controller->getConfig();
     if (!isset($_SERVER['Shib-Application-ID'])) {
         header('Location: ' . $config->getShibbolethLoginUrl());
         exit(0);
     }
     if (!isset($_SERVER[$config->getShibbolethUsernameAttribute()])) {
         throw new \Jazzee\Exception($config->getShibbolethUsernameAttribute() . ' attribute is missing from authentication source.');
     }
     $uniqueName = $_SERVER[$config->getShibbolethUsernameAttribute()];
     $firstName = isset($_SERVER[$config->getShibbolethFirstNameAttribute()]) ? $_SERVER[$config->getShibbolethFirstNameAttribute()] : null;
     $lastName = isset($_SERVER[$config->getShibbolethLastNameAttribute()]) ? $_SERVER[$config->getShibbolethLastNameAttribute()] : null;
     $mail = isset($_SERVER[$config->getShibbolethEmailAddressAttribute()]) ? $_SERVER[$config->getShibbolethEmailAddressAttribute()] : null;
     $this->_controller->getStore()->expire();
     $this->_controller->getStore()->touchAuthentication();
     $this->_user = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\User')->findOneBy(array('uniqueName' => $uniqueName, 'isActive' => true));
     if (!$this->_user) {
         //creat a new user
         $this->_user = new \Jazzee\Entity\User();
         $this->_user->setUniqueName($uniqueName);
         //persist and flush a new user early so we get the ID for the authenticaiton logs
         $this->_controller->getEntityManager()->persist($this->_user);
         $this->_controller->getEntityManager()->flush();
     }
     $this->_controller->getStore()->set(self::SESSION_VAR_ID, $this->_user->getId());
     $this->_controller->getEntityManager()->persist($this->_user);
     $this->_user->setFirstName($firstName);
     $this->_user->setLastName($lastName);
     $this->_user->setEmail($mail);
 }
예제 #3
0
 public function loginUser()
 {
     $form = $this->getLoginForm();
     if ($form->processInput($_POST)) {
         if ($this->isAllowedIp($_SERVER['REMOTE_ADDR'])) {
             $this->_user = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\User')->findOneBy(array('id' => $_POST['userid'], 'isActive' => true));
             $this->_controller->getStore()->expire();
             $this->_controller->getStore()->touchAuthentication();
             $this->_controller->getStore()->set(self::SESSION_VAR_ID, $this->_user->getId());
         } else {
             throw new \Jazzee\Exception("{$_SERVER['REMOTE_ADDR']} is not a valid ip address for NoAuthentication.  Add it to the noAuthIpAddresses configuration to continue.");
         }
     }
 }
예제 #4
0
 /**
  * Get an applicant by ID
  * Ensures we are fetching an applicant from our current program and cycle
  * @param integer $applicantId
  * @return \Jazzee\Entity\Applicant
  *
  */
 protected function getApplicantById($applicantId)
 {
     if (!($applicant = $this->_em->getRepository('\\Jazzee\\Entity\\Applicant')->find($applicantId, false)) or $applicant->getApplication() != $this->_application) {
         throw new Exception($this->_user->getFirstName() . ' ' . $this->_user->getLastName() . ' (#' . $this->_user->getId() . ") attempted to access applicant {$applicantId} who is not in their current program", E_USER_ERROR, 'That applicant does not exist or is not in your current program');
     }
     return $applicant;
 }
예제 #5
0
 public function loginUser()
 {
     $form = $this->getLoginForm();
     if ($input = $form->processInput($_POST)) {
         $allowedIps = explode(',', $this->_controller->getConfig()->getApiFormAuthenticationIpAddresses());
         if (in_array($_SERVER['REMOTE_ADDR'], $allowedIps)) {
             if ($this->_user = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\User')->findOneBy(array('apiKey' => $input->get('apiKey'), 'isActive' => true))) {
                 $this->_controller->getStore()->expire();
                 $this->_controller->getStore()->touchAuthentication();
                 $this->_controller->getStore()->set(self::SESSION_VAR_ID, $this->_user->getId());
             } else {
                 $form->getElementByName('apiKey')->addMessage('That is not a valid ID');
                 return false;
             }
         } else {
             throw new \Jazzee\Exception("{$_SERVER['REMOTE_ADDR']} is not a valid ip address for ApiFormAuthentication: {$allowedIps}.  Add it to the apiFormAuthenticationIpAddresses configuration to continue.");
         }
     }
 }