diff options
| author | Sebastian Wagner | 2011-03-25 14:05:02 +0100 |
|---|---|---|
| committer | Sebastian Wagner | 2011-03-25 14:05:02 +0100 |
| commit | 74b5442e180e2c42d19d1b8c411c503d7c47f0a4 (patch) | |
| tree | 661e4cec9221a4afeca0beceda6c723a12bcf01f /application/modules/fbgui/controllers/AuthController.php | |
| parent | test (diff) | |
| download | pbs2-74b5442e180e2c42d19d1b8c411c503d7c47f0a4.tar.gz pbs2-74b5442e180e2c42d19d1b8c411c503d7c47f0a4.tar.xz pbs2-74b5442e180e2c42d19d1b8c411c503d7c47f0a4.zip | |
fbgui auth configuriert
Diffstat (limited to 'application/modules/fbgui/controllers/AuthController.php')
| -rw-r--r-- | application/modules/fbgui/controllers/AuthController.php | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/application/modules/fbgui/controllers/AuthController.php b/application/modules/fbgui/controllers/AuthController.php index 16c5d7c..e9b6666 100644 --- a/application/modules/fbgui/controllers/AuthController.php +++ b/application/modules/fbgui/controllers/AuthController.php @@ -5,22 +5,73 @@ class Fbgui_AuthController extends Zend_Controller_Action public function init() { - /* Initialize action controller here */ + $this->db = Zend_Db_Table::getDefaultAdapter(); + $this->personmapper = new Application_Model_PersonMapper(); } public function indexAction() { - // action body + $this->_helper-> viewRenderer-> setNoRender(); + $this->_helper->redirector('login', 'auth'); } public function loginAction() { - // action body + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->_redirect('/user/'); + } else { + if (!isset($_POST["login"])){ + $loginForm = new user_Form_Login(); + } else { + $loginForm = new user_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('email', Zend_Auth::getInstance()->getIdentity()); + $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() { - // action body + $this->_helper-> viewRenderer-> setNoRender(); + $auth = Zend_Auth::getInstance(); + $auth->clearIdentity(); + Zend_Session::namespaceUnset('userIDs'); + $this->_helper->redirector('login', 'auth'); + return; } |
