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()); }
public function do_unskip() { $answers = $this->_applicant->findAnswersByPage($this->_applicationPage->getPage()); if (count($answers) and $answers[0]->getPageStatus() == self::SKIPPED) { $this->_applicant->getAnswers()->removeElement($answers[0]); $this->_controller->getEntityManager()->remove($answers[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."); } } }
/** * @SuppressWarnings(PHPMD.ExitExpression) */ public function loginUser() { $returnTo = $this->_controller->absolutePath('login'); $realm = $this->_controller->absoluetPath(''); if (!empty($_POST['openid_identifier'])) { $identifier = $_POST['openid_identifier']; $relayParty = new \OpenID_RelyingParty($returnTo, $realm, $identifier); $authRequest = $relayParty->prepare(); $authExtension = new \OpenID_Extension_AX(\OpenID_Extension::REQUEST); $authExtension->set('type.email', 'http://axschema.org/contact/email'); $authExtension->set('type.firstname', 'http://axschema.org/namePerson/first'); $authExtension->set('type.lastname', 'http://axschema.org/namePerson/last'); $authExtension->set('mode', 'fetch_request'); $authExtension->set('required', 'email,firstname,lastname'); $authRequest->addExtension($authExtension); header('Location: ' . $authRequest->getAuthorizeURL()); exit(0); } $relayParty = new \OpenID_RelyingParty($returnTo, $realm); $arr = explode('?', $_SERVER['REQUEST_URI']); $queryString = isset($arr[1]) ? $arr[1] : ''; if ($queryString) { $message = new \OpenID_Message($queryString, \OpenID_Message::FORMAT_HTTP); $result = $relayParty->verify(new \Net_URL2($returnTo), $message); if ($result->success()) { $this->_controller->getStore()->expire(); $this->_controller->getStore()->touchAuthentication(); $authExtension = new \OpenID_Extension_AX(\OpenID_Extension::RESPONSE, $message); $uniqueName = $message->get('openid.claimed_id'); $email = $authExtension->get('value.email'); $firstName = $authExtension->get('value.firstname'); $lastName = $authExtension->get('value.lastname'); $this->_controller->getStore()->set(self::SESSION_VAR_ID, $uniqueName); $user = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\User')->findOneBy(array('uniqueName' => $uniqueName)); if (!$user) { $user = new \Jazzee\Entity\User(); $user->setUniqueName($uniqueName); } $user->setFirstName($firstName); $user->setLastName($lastName); $user->setEmail($email); $this->_controller->getEntityManager()->persist($user); $this->_user = $user; } } }
/** * Get the login form * * @return \Foundation\Form */ public function getLoginForm() { if (is_null($this->_form)) { $this->_form = new \Foundation\Form(); $this->_form->setCSRFToken($this->_controller->getCSRFToken()); $this->_form->setAction($this->_controller->path("login")); $field = $this->_form->newField(); $field->setLegend('Select a user'); $element = $field->newElement('SelectList', 'userid'); $element->setLabel('User'); $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element)); foreach ($this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\User')->findByName('%', '%') as $user) { if ($user->isActive()) { $element->newItem($user->getId(), "{$user->getLastName()}, {$user->getFirstName()} - {$user->getEmail()}"); } } $this->_form->newButton('submit', 'Login'); } return $this->_form; }
/** * By default just set the varialbe dont check it * @param string $name * @param string $value */ public function setVar($name, $value) { $var = $this->_applicationPage->getPage()->setVar($name, $value); $this->_controller->getEntityManager()->persist($var); }