summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorSimon2011-01-31 15:09:44 +0100
committerSimon2011-01-31 15:09:44 +0100
commit8e1302857fb4350bb68a7b334a183ba68c59e91c (patch)
treefc5bf3e8c958fb8c90e48182e57d10942db0d645 /application
parentMerge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff)
downloadpbs2-8e1302857fb4350bb68a7b334a183ba68c59e91c.tar.gz
pbs2-8e1302857fb4350bb68a7b334a183ba68c59e91c.tar.xz
pbs2-8e1302857fb4350bb68a7b334a183ba68c59e91c.zip
Login funktioniert
Diffstat (limited to 'application')
-rw-r--r--application/Bootstrap.php4
-rw-r--r--application/controllers/AuthController.php24
-rw-r--r--application/controllers/PersonController.php15
-rw-r--r--application/views/scripts/auth/login.phtml5
-rw-r--r--application/views/scripts/index/index.phtml8
5 files changed, 25 insertions, 31 deletions
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index 26169dd..6ac8a0e 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -3,5 +3,9 @@
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
+ protected function _initAuth(){
+ $auth = Zend_Auth::getInstance();
+ $auth->setStorage(new Zend_Auth_Storage_Session('auth'));
+ }
}
diff --git a/application/controllers/AuthController.php b/application/controllers/AuthController.php
index 070c2e8..cc0bca2 100644
--- a/application/controllers/AuthController.php
+++ b/application/controllers/AuthController.php
@@ -12,6 +12,9 @@ class AuthController extends Zend_Controller_Action
$loginForm = new Application_Form_AuthLogin($_POST);
if ($loginForm->isValid($_POST)) {
+
+ $auth = Zend_Auth::getInstance();
+
$adapter = new Zend_Auth_Adapter_DbTable(
$db,
'pbs_person',
@@ -19,20 +22,19 @@ class AuthController extends Zend_Controller_Action
'password',
'MD5(CONCAT(?, password_salt))'
);
-
+
+
$adapter->setIdentity($loginForm->getValue('email'));
$adapter->setCredential($loginForm->getValue('password'));
-
- $result = $adapter->authenticate();
-
+
+ $result = $auth->authenticate($adapter);
+
+ // TODO: erweiterte fehlerbeschreibung des Users
+ // siehe http://framework.zend.com/manual/en/zend.auth.introduction.html
+
if ($result->isValid()) {
- //$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('/');
+ #$this->_helper->FlashMessenger('Erfolgreich angemeldet');
+ $this->_redirect('/');
return;
} else {
//$this->_helper->FlashMessenger('E-Mail oder Passwort falsch');
diff --git a/application/controllers/PersonController.php b/application/controllers/PersonController.php
index 9a8aea2..a0b2faf 100644
--- a/application/controllers/PersonController.php
+++ b/application/controllers/PersonController.php
@@ -3,20 +3,17 @@
class PersonController extends Zend_Controller_Action
{
- public function init()
+ public function preDispatch()
{
-
+ if (!Zend_Auth::getInstance()->hasIdentity()) {
+ // TODO: quick hack fixxen
+ $this->_redirect('/Auth/login');
+ }
}
public function indexAction()
{
- if (!Zend_Auth::getInstance()->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 0618564..0242bc6 100644
--- a/application/views/scripts/auth/login.phtml
+++ b/application/views/scripts/auth/login.phtml
@@ -2,8 +2,7 @@
$this->loginForm->setAction($this->url());
echo $this->loginForm;
-echo "<pre>";
-print_r($_SESSION);
-echo "</pre>";
+
+
?>
diff --git a/application/views/scripts/index/index.phtml b/application/views/scripts/index/index.phtml
index b3c2b57..487bd28 100644
--- a/application/views/scripts/index/index.phtml
+++ b/application/views/scripts/index/index.phtml
@@ -1,9 +1 @@
-<?php
-echo "already logged in as: " . Zend_Auth::getInstance()->getIdentity();
-echo "<pre>";
-print_r($_SESSION);
-echo "</pre>";
-Zend_Debug::dump($_SESSION, $label="_SESSION nach Login: ", $echo=true);
- $this->view->loginStatus = "Eingeloggt als " . $this->_userNamespace->username;
-?>
<h1>Zend-Framework Index</h1>