From abedb634fe938e85f68d9be5223c97e392e047cc Mon Sep 17 00:00:00 2001 From: Björn Geiger Date: Mon, 11 Apr 2011 14:37:44 +0200 Subject: Bessere Fehlerbeschreibung bei Registrierung --- .../modules/user/controllers/AuthController.php | 27 +++++++++++----------- .../modules/user/views/scripts/auth/login.phtml | 1 + .../modules/user/views/scripts/auth/register.phtml | 3 ++- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/application/modules/user/controllers/AuthController.php b/application/modules/user/controllers/AuthController.php index 8160104..bb16e94 100644 --- a/application/modules/user/controllers/AuthController.php +++ b/application/modules/user/controllers/AuthController.php @@ -45,8 +45,6 @@ class User_AuthController extends Zend_Controller_Action $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); @@ -58,7 +56,8 @@ class User_AuthController extends Zend_Controller_Action $this->_helper->redirector('selectmembership', 'person'); return; } else { - echo "Wrong Email or Password."; + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Wrong Email or Password', 'error'); } } } @@ -80,34 +79,34 @@ class User_AuthController extends Zend_Controller_Action public function registerAction() { if (Zend_Auth::getInstance()->hasIdentity()) { - print_a('Already logged in.'); + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Already logged in.', 'error'); } else { if (!isset($_POST["register"])){ $registerForm = new user_Form_Register(); } else { - $registerForm = new user_Form_Register($_POST); - + foreach($_POST as $k => $v) { + if($v != '') { + $data[$k] = $v; + } + } + $registerForm = new user_Form_Register($data); if ($registerForm->isValid($_POST)) { - $person = new Application_Model_Person($_POST); $this->personmapper = new Application_Model_PersonMapper(); - $date = new DateTime(); $person->setRegisterdate($date->getTimestamp()); $person->setPasswordSalt(MD5($date->getTimestamp())); $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); - print_a($person); try { $this->personmapper->save($person); }catch(Zend_Exception $e) { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - echo "Email Address already existing.."; + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Email already registered', 'error'); + $this->view->registerForm = $registerForm; return; } - echo "Successfully registered.
"; - echo "Continue to Login: Login"; $this->_helper->redirector('login', 'auth'); return; } diff --git a/application/modules/user/views/scripts/auth/login.phtml b/application/modules/user/views/scripts/auth/login.phtml index 899c6e7..cc2a3ef 100644 --- a/application/modules/user/views/scripts/auth/login.phtml +++ b/application/modules/user/views/scripts/auth/login.phtml @@ -1,6 +1,7 @@

Login

loginForm->setAction($this->url()); +echo $this->notification; echo $this->loginForm; ?>
\ No newline at end of file diff --git a/application/modules/user/views/scripts/auth/register.phtml b/application/modules/user/views/scripts/auth/register.phtml index 6217e06..eb59c68 100644 --- a/application/modules/user/views/scripts/auth/register.phtml +++ b/application/modules/user/views/scripts/auth/register.phtml @@ -1,5 +1,6 @@

New Account

notification; $this->registerForm->setAction($this->url()); echo $this->registerForm; -?> \ No newline at end of file +?> -- cgit v1.2.3-55-g7522