From 73d6a1a8bd1cd9ba6c1372d090d49a671dbb610e Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 31 Jan 2011 13:07:11 +0100 Subject: bootstrap und login funktionieren --- application/controllers/AuthController.php | 62 ++++++++++++++---------------- 1 file changed, 28 insertions(+), 34 deletions(-) (limited to 'application/controllers/AuthController.php') diff --git a/application/controllers/AuthController.php b/application/controllers/AuthController.php index c054437..0a2c8c0 100644 --- a/application/controllers/AuthController.php +++ b/application/controllers/AuthController.php @@ -2,45 +2,39 @@ class AuthController extends Zend_Controller_Action { - public function loginAction() { - $db = $this->_getParam('pbs_person'); + $db = Zend_Db_Table::getDefaultAdapter(); + if (!isset($_POST["login"])){ - $loginForm = new Application_Form_AuthLogin(); + $loginForm = new Application_Form_AuthLogin(); } else { + $loginForm = new Application_Form_AuthLogin($_POST); + + if ($loginForm->isValid($_POST)) { + $adapter = new Zend_Auth_Adapter_DbTable( + $db, + 'pbs_person', + 'email', + 'password', + 'MD5(CONCAT(?, password_salt))' + ); + + $adapter->setIdentity($loginForm->getValue('email')); + $adapter->setCredential($loginForm->getValue('password')); + + $result = $adapter->authenticate(); + + if ($result->isValid()) { + //$this->_helper->FlashMessenger('Erfolgreich angemeldet'); + $this->_redirect('/'); + return; + } else { + //$this->_helper->FlashMessenger('E-Mail oder Passwort falsch'); + } + } + } - $loginForm = new Application_Form_AuthLogin($_POST); - - if ($loginForm->isValid($_POST)) { - - $adapter = new Zend_Auth_Adapter_DbTable( - $db, - 'users', - 'username', - 'password', - 'MD5(CONCAT(?, password_salt))' - ); - - $adapter->setIdentity($loginForm->getValue('email')); - $adapter->setCredential($loginForm->getValue('password')); - - $result = $auth->authenticate($adapter); - - if ($result->isValid()) { - $this->_helper->FlashMessenger('Erfolgreich angemeldet'); - $this->redirect('/'); - return; - } - - } - } $this->view->loginForm = $loginForm; - } - - } - - - -- cgit v1.2.3-55-g7522 From c142c466c6cc2efaec799334bbf36b514d1d1055 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 31 Jan 2011 13:55:22 +0100 Subject: authController geƤnder --- .zfproject.xml | 7 +++ application/Bootstrap.php | 1 + application/controllers/AuthController.php | 9 +++- application/controllers/PersonController.php | 26 +++++++++++ application/views/scripts/auth/login.phtml | 4 ++ application/views/scripts/index/index.phtml | 52 ++++------------------ application/views/scripts/person/index.phtml | 1 + .../controllers/PersonControllerTest.php | 20 +++++++++ 8 files changed, 75 insertions(+), 45 deletions(-) create mode 100644 application/controllers/PersonController.php create mode 100644 application/views/scripts/person/index.phtml create mode 100644 tests/application/controllers/PersonControllerTest.php (limited to 'application/controllers/AuthController.php') diff --git a/.zfproject.xml b/.zfproject.xml index c760b0b..ead4122 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -16,6 +16,9 @@ + + + @@ -106,6 +109,9 @@ + + + @@ -141,6 +147,7 @@ + diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 0a6a407..26169dd 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -2,5 +2,6 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { + } diff --git a/application/controllers/AuthController.php b/application/controllers/AuthController.php index 0a2c8c0..070c2e8 100644 --- a/application/controllers/AuthController.php +++ b/application/controllers/AuthController.php @@ -26,8 +26,13 @@ class AuthController extends Zend_Controller_Action $result = $adapter->authenticate(); if ($result->isValid()) { - //$this->_helper->FlashMessenger('Erfolgreich angemeldet'); - $this->_redirect('/'); + //$this->_helper->FlashMessenger('Erfolgreich angemeldet'); + $this->_userNamespace->username = 'testt'; + + Zend_Debug::dump($_SESSION, $label="_SESSION nach Login: ", $echo=true); + Zend_Debug::dump($this->_userNamespace, $label="userNamespace: ", $echo=true); + $this->view->loginStatus = "Eingeloggt als " . $this->_userNamespace->username; + #$this->_redirect('/'); return; } else { //$this->_helper->FlashMessenger('E-Mail oder Passwort falsch'); diff --git a/application/controllers/PersonController.php b/application/controllers/PersonController.php new file mode 100644 index 0000000..9a8aea2 --- /dev/null +++ b/application/controllers/PersonController.php @@ -0,0 +1,26 @@ +hasIdentity()) { + echo 'case1'; + + + echo "already logged in as: " . Zend_Auth::getInstance()->getIdentity(); + #$this->_redirect($this->url(array('Auth','login'))); + } + echo 'case2'; + // action body + } + + +} + diff --git a/application/views/scripts/auth/login.phtml b/application/views/scripts/auth/login.phtml index 8312487..0618564 100644 --- a/application/views/scripts/auth/login.phtml +++ b/application/views/scripts/auth/login.phtml @@ -1,5 +1,9 @@ loginForm->setAction($this->url()); echo $this->loginForm; + +echo "
"; 
+print_r($_SESSION);
+echo "
"; ?> diff --git a/application/views/scripts/index/index.phtml b/application/views/scripts/index/index.phtml index 4b38f0a..b3c2b57 100644 --- a/application/views/scripts/index/index.phtml +++ b/application/views/scripts/index/index.phtml @@ -1,43 +1,9 @@ - -
-

Welcome to the Zend Framework!

- -

This is your project's main page

- -
-

-

- Helpful Links:
- Zend Framework Website | - Zend Framework Manual -

-
-
\ No newline at end of file +getIdentity(); +echo "
"; 
+print_r($_SESSION);
+echo "
"; +Zend_Debug::dump($_SESSION, $label="_SESSION nach Login: ", $echo=true); + $this->view->loginStatus = "Eingeloggt als " . $this->_userNamespace->username; +?> +

Zend-Framework Index

diff --git a/application/views/scripts/person/index.phtml b/application/views/scripts/person/index.phtml new file mode 100644 index 0000000..7a96e97 --- /dev/null +++ b/application/views/scripts/person/index.phtml @@ -0,0 +1 @@ +

View script for controller Person and script/action name index
\ No newline at end of file diff --git a/tests/application/controllers/PersonControllerTest.php b/tests/application/controllers/PersonControllerTest.php new file mode 100644 index 0000000..351702e --- /dev/null +++ b/tests/application/controllers/PersonControllerTest.php @@ -0,0 +1,20 @@ +