summaryrefslogblamecommitdiffstats
path: root/application/controllers/AuthController.php
blob: 070c2e81c95ca91c30f491a6954d6bb18aa21624 (plain) (tree)
1
2
3
4
5
6
7
8
9



                                                   

                                 

                                                 
                                             
                                                              
                        
















                                                                                  






                                                                                                                          





                                                                                                        
 
                                            
     
 
<?php

class AuthController extends Zend_Controller_Action
{
    public function loginAction()
    {         
        $db = Zend_Db_Table::getDefaultAdapter();

 		if (!isset($_POST["login"])){
	        $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->_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');
				} 
		    }
		}

        $this->view->loginForm = $loginForm;
    }
}