From fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Wed, 11 Jan 2012 14:36:35 +0100 Subject: format source files --- .../modules/fbgui/controllers/AuthController.php | 153 ++++++++++----------- 1 file changed, 74 insertions(+), 79 deletions(-) (limited to 'application/modules/fbgui/controllers/AuthController.php') diff --git a/application/modules/fbgui/controllers/AuthController.php b/application/modules/fbgui/controllers/AuthController.php index 936aa61..f51d89f 100644 --- a/application/modules/fbgui/controllers/AuthController.php +++ b/application/modules/fbgui/controllers/AuthController.php @@ -1,84 +1,79 @@ -db = Zend_Db_Table::getDefaultAdapter(); - $this->personmapper = new Application_Model_PersonMapper(); - } - - public function indexAction() - { - $this->_helper-> viewRenderer-> setNoRender(); - $this->_helper->redirector('login', 'auth'); - } - - public function loginAction() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $this->_redirect('/fbgui/'); - } else { - if (!isset($_POST["login"])){ - $loginForm = new fbgui_Form_Login(); - } else { - $loginForm = new fbgui_Form_Login($_POST); - - if ($loginForm->isValid($_POST)) { - - $auth = Zend_Auth::getInstance(); - - $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'pbs_person', 'email', 'password', 'MD5(CONCAT(?, password_salt))'); - - - $adapter->setIdentity($loginForm->getValue('email')); - $adapter->setCredential($loginForm->getValue('password')); - - $result = $auth->authenticate($adapter); - - // TODO: erweiterte fehlerbeschreibung des Users - - if ($result->isValid()) { - $this->personmapper = new Application_Model_PersonMapper(); - $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); - $person = new Application_Model_Person($result[0]); - $person->setID($result[0]['personID']); - $date = new DateTime(); - $person->setLogindate($date->getTimestamp()); - $this->personmapper->save($person); - $this->_helper->redirector('selectmembership', 'person'); - return; - } else { - echo "Wrong Email or Password."; - } - } - } - $this->view->loginForm = $loginForm; - } - } - - public function logoutAction() - { - $this->_helper-> viewRenderer-> setNoRender(); - $auth = Zend_Auth::getInstance(); - $auth->clearIdentity(); - Zend_Session::namespaceUnset('userIDs'); - Zend_Session::forgetMe(); - $this->_redirect('/fbgui/index'); -# $this->_helper->redirector('fbgui', 'index'); - return; - } +* This program is free software distributed under the GPL version 2. +* See http://gpl.openslx.org/ +* +* If you have any feedback please consult http://feedback.openslx.org/ and +* send your suggestions, praise, or complaints to feedback@openslx.org +* +* General information about OpenSLX can be found at http://openslx.org/ +*/ + +class Fbgui_AuthController extends Zend_Controller_Action { + + public function init() { + $this->db = Zend_Db_Table::getDefaultAdapter(); + $this->personmapper = new Application_Model_PersonMapper(); + } + + public function indexAction() { + $this->_helper-> viewRenderer-> setNoRender(); + $this->_helper->redirector('login', 'auth'); + } + + public function loginAction() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->_redirect('/fbgui/'); + } else { + if (!isset($_POST["login"])) { + $loginForm = new fbgui_Form_Login(); + } else { + $loginForm = new fbgui_Form_Login($_POST); + + if ($loginForm->isValid($_POST)) { + + $auth = Zend_Auth::getInstance(); + + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'pbs_person', 'email', 'password', 'MD5(CONCAT(?, password_salt))'); + + + $adapter->setIdentity($loginForm->getValue('email')); + $adapter->setCredential($loginForm->getValue('password')); + + $result = $auth->authenticate($adapter); + + // TODO: erweiterte fehlerbeschreibung des Users + + if ($result->isValid()) { + $this->personmapper = new Application_Model_PersonMapper(); + $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()), true); + $person = new Application_Model_Person($result[0]); + $person->setID($result[0]['personID']); + $date = new DateTime(); + $person->setLogindate($date->getTimestamp()); + $this->personmapper->save($person); + $this->_helper->redirector('selectmembership', 'person'); + return; + } else { + echo "Wrong Email or Password."; + } + } + } + $this->view->loginForm = $loginForm; + } + } + + public function logoutAction() { + $this->_helper-> viewRenderer-> setNoRender(); + $auth = Zend_Auth::getInstance(); + $auth->clearIdentity(); + Zend_Session::namespaceUnset('userIDs'); + Zend_Session::forgetMe(); + $this->_redirect('/fbgui/index'); +# $this->_helper->redirector('fbgui', 'index'); + return; + } } -- cgit v1.2.3-55-g7522