getInvokeArg('bootstrap'); $this->config = $bootstrap->getOptions(); $this->pbs2host = $this->config['pbs2']['host']; $this->pbs2Api = new Poolctrl_Pbs2Api($this->config); $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); if(isset($this->userIDsNamespace['apikey'])) { $this->acl = new Poolctrl_Acl($this->pbs2host, $this->config['pbs2']['checkright'] . $this->userIDsNamespace['apikey'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); } } public function indexAction() { $this->_helper->redirector('login', 'auth'); } public function loginAction() { if (Zend_Auth::getInstance()->hasIdentity()) { $this->_redirect('/'); } else { if (!isset($_POST["login"])){ $loginForm = new Application_Form_Login(); } else { $loginForm = new Application_Form_Login($_POST); if ($loginForm->isValid($_POST)) { $membershipSession = new Zend_Session_Namespace('memberships'); $error = ""; $personID = ""; $apikey = ""; if($this->pbs2Api->login($loginForm->getValue('email'), $loginForm->getValue('password'), $membershipSession, $error, $personID, $apikey)) { $membershipNamespace = $membershipSession->getIterator(); $personSession = new Zend_Session_Namespace('persons'); $this->pbs2Api->getPerson($personSession, $apikey); $userSession = new Zend_Session_Namespace('userIDs'); $userSession->personID = sprintf("%s", $personID); $authSession = new Zend_Session_Namespace('auth'); $authSession->storage = $loginForm->getValue('email'); $this->_helper->redirector('selectmembership', 'person'); } else { if($error == "wrong email or password") { $poolctrlNotifier = new Poolctrl_Notifier(); $this->view->notification = $poolctrlNotifier->notify('Wrong Email or Password', 'error'); } else if($error == "person suspended") { $poolctrlNotifier = new Poolctrl_Notifier(); $this->view->notification = $poolctrlNotifier->notify('Your Account is suspended', 'error'); } } } } $this->view->loginForm = $loginForm; } } public function logoutAction() { $this->_helper-> viewRenderer-> setNoRender(); $auth = Zend_Auth::getInstance(); $auth->clearIdentity(); Zend_Session::namespaceUnset('userIDs'); Zend_Session::namespaceUnset('memberships'); Zend_Session::namespaceUnset('persons'); Zend_Session::namespaceUnset('groups'); Zend_Session::namespaceUnset('roles'); Zend_Session::forgetMe(); $this->_helper->redirector('login', 'auth'); return; } }