summaryrefslogtreecommitdiffstats
path: root/application/controllers/AuthController.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/controllers/AuthController.php')
-rw-r--r--application/controllers/AuthController.php70
1 files changed, 49 insertions, 21 deletions
diff --git a/application/controllers/AuthController.php b/application/controllers/AuthController.php
index 4264e7b..fd30d82 100644
--- a/application/controllers/AuthController.php
+++ b/application/controllers/AuthController.php
@@ -3,10 +3,14 @@
class AuthController extends Zend_Controller_Action
{
- public function loginAction()
+ public function init()
{
- $db = Zend_Db_Table::getDefaultAdapter();
-
+ $db = Zend_Db_Table::getDefaultAdapter();
+
+ }
+
+ public function loginAction()
+ {
if (!isset($_POST["login"])){
$loginForm = new Application_Form_AuthLogin();
} else {
@@ -31,14 +35,12 @@ class AuthController extends Zend_Controller_Action
$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->_redirect('/');
return;
} else {
- //$this->_helper->FlashMessenger('E-Mail oder Passwort falsch');
+ echo "Falsche Email oder Passwort";
}
}
}
@@ -47,25 +49,35 @@ class AuthController extends Zend_Controller_Action
}
public function registerAction()
- {
- $db = Zend_Db_Table::getDefaultAdapter();
-
+ {
if (!isset($_POST["register"])){
$registerForm = new Application_Form_AuthRegister();
} else {
$registerForm = new Application_Form_AuthRegister($_POST);
-
+
if ($registerForm->isValid($_POST)) {
+
$person = new Application_Model_Person($_POST);
- if ($person != null) {
- echo "Erfolgreich registriert";
- var_dump($person);
- //$this->_redirect('/auth/login');
- return;
- } else {
- echo "Die angegebene Email-Adresse existiert bereits";
- }
- }
+ $personmapper = new Application_Model_PersonMapper();
+
+ $date = new DateTime();
+ $person->setRegisterdate($date->getTimestamp());
+ $person->setPasswordSalt(MD5($date->getTimestamp()));
+ $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt()));
+
+ try {
+ $personmapper->save($person);
+ }catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ echo "Email Adresse bereits vorhanden.";
+ return;
+ }
+ echo "Erfolgreich registriert. <br/>";
+ echo "Weiter zum Login: <a href=\""."/auth/login"."\">Login</a>";
+ return;
+ }
}
$this->view->registerForm = $registerForm;
@@ -81,9 +93,25 @@ class AuthController extends Zend_Controller_Action
// action body
}
- public function deleteAccountAction()
+ public function deleteAction()
{
- // action body
+ if (!isset($_POST["delete"])){
+ $deleteForm = new Application_Form_AuthDelete();
+ } else {
+ $deleteForm = new Application_Form_AuthDelete($_POST);
+
+ if ($deleteForm->isValid($_POST)) {
+
+ $person = new Application_Model_Person($_POST);
+ $personmapper = new Application_Model_PersonMapper();
+
+
+ $personmapper->delete($person);
+ }
+ }
+
+ $this->view->deleteForm = $deleteForm;
+
}