Пример #1
0
 public function loginAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $this->_helper->redirector('index', 'index');
     }
     $loginForm = new Application_Form_Auth_Login();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $formData = $this->_request->getPost();
         if ($loginForm->isValid($formData)) {
             $username = $this->getRequest()->getParam('username');
             $password = Unplagged_Helper::hashString($this->getRequest()->getParam("password"));
             $adapter = new Unplagged_Auth_Adapter_Doctrine($this->_em, "Application_Model_Personnel", "username", "password", $username, $password);
             $result = $auth->authenticate($adapter);
             if ($result->isValid()) {
                 $defaultNamespace = new Zend_Session_Namespace('Default');
                 $defaultNamespace->user = $result->getIdentity();
                 $this->_helper->flashMessenger->addMessage('Sie wurden erfolgreich am System angemeldet.');
                 $this->_helper->redirector('index', 'index');
             } else {
                 $this->_helper->flashMessenger->addMessage('Das Login ist fehlgeschlagen.');
                 $this->_helper->redirector('login', 'auth');
             }
         }
     }
     $this->view->loginForm = $loginForm;
 }
Пример #2
0
 public function loginAction()
 {
     $db = $this->_getParam('db');
     $loginForm = new Application_Form_Auth_Login();
     if ($loginForm->isValid($_POST)) {
         $adapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password', 'MD5(CONCAT(?,password_salt))');
         $adapter->setIdentity($loginForm->getValue('username'));
         $adapter->setIdentity($loginForm->getValue('password'));
         $auth = Zend_Auth::getInstance();
         $result = $auth->authenticate($adapter);
         if ($result->isValid()) {
             $this->_helper->FlashMessanger('Successfull Login');
             $this->_redirect('/');
             return;
         }
     }
     $this->view->loginForm = $loginForm;
 }
Пример #3
0
 public function loginAction()
 {
     $auth = Zend_Auth::getInstance();
     $identity = $auth->getIdentity();
     //        $registry = Zend_Registry::getInstance();
     if ($identity && $identity != "") {
         $this->_helper->redirector('index', 'index');
     } else {
         $authTable = new Application_Model_DbTable_Actor();
         $loginForm = new Application_Form_Auth_Login($_POST);
         $modelUser = new Application_Model_User();
         $loginForm->getElement('submit')->setOptions(array('class' => 'button-style'));
         if ($loginForm->isValid($_POST)) {
             $adapter = new Zend_Auth_Adapter_DbTable($authTable->getAdapter(), 'actor', 'login', 'password', 'MD5(CONCAT(?, password_salt))');
             $adapter->setIdentity($loginForm->getValue('Email'));
             $adapter->setCredential($loginForm->getValue('Password'));
             $result = $auth->authenticate($adapter);
             if ($result->isValid()) {
                 #$authSession = Zend_Session_Namespace::getInstance('');
                 //                    $registry->set('id', $id);
                 //$this->_helper->FlashMessenger('Successful Login');
                 $siteInfoNamespace = new Zend_Session_Namespace('siteInfoNamespace');
                 $userInfo = $modelUser->getAll($loginForm->getValue('Email'));
                 $modelUser->updateLastLogin($userInfo['ID']);
                 $siteInfoNamespace->userId = $userInfo['ID'];
                 $siteInfoNamespace->Firstname = $userInfo['name'];
                 $siteInfoNamespace->username = $userInfo['login'];
                 $siteInfoNamespace->password = $loginForm->getValue('Password');
                 if ($siteInfoNamespace->requestURL) {
                     $redirectURL = $siteInfoNamespace->requestURL;
                     $siteInfoNamespace->requestURL = "";
                     $this->_helper->redirector($redirectURL['action'], $redirectURL['controller'], $redirectURL['module']);
                 } else {
                     $this->_helper->redirector('index', 'index');
                 }
                 return;
             } else {
                 $layout = Zend_Layout::getMvcInstance();
                 $layout->setLayout('layout.login');
                 $code = array();
                 switch ($result->getCode()) {
                     case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
                         $auth_error = "Username not found!";
                         $code[$result->getCode()] = "Username not found!";
                         break;
                     case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
                         $auth_error = "Invalid password!";
                         $code[$result->getCode()] = "Invalid password!";
                         break;
                     case Zend_Auth_Result::SUCCESS:
                         $code[$result->getCode()] = "success";
                         break;
                     case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS:
                         $code[$result->getCode()] = "ambiguous";
                         break;
                     default:
                         break;
                 }
                 $this->view->auth_code = $code;
                 $this->view->auth_error = $auth_error;
             }
         } else {
             $layout = Zend_Layout::getMvcInstance();
             $layout->setLayout('layout.login');
         }
     }
     $this->view->loginForm = $loginForm;
 }