public function indexAction()
 {
     //$this->_helper->layout ()->disableLayout ();
     $auth = Zend_Auth::getInstance();
     $authContent = $auth->getStorage()->read();
     $authAcl = new Zend_Session_Namespace('authAcl');
     $guestID = Authz_Resource_Acl_Guest::GUEST_ID;
     if (is_array($authContent) and $authContent['identity'] != $guestID) {
         return;
     }
     $loginForm = new Auth_Form_Auth_Login($_POST);
     $authAdapter = null;
     if ($this->getRequest()->isPost() and $loginForm->isValid($_POST)) {
         $authService = 'DbTable';
         switch (strtolower($authService)) {
             case 'dbtable':
                 $db = $this->_getParam('db');
                 $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'auth_user', 'user_id', 'sec_passwd');
                 $authAdapter->setIdentity($loginForm->getValue('username'));
                 $authAdapter->setCredential($loginForm->getValue('password'));
                 break;
             case 'ldap':
                 /*TODO Implement LDAP auth */
                 break;
             default:
                 throw new Zend_Exception('Unknown authentication service -> ' . $authService, Zend_Log::ALERT);
         }
         $result = Zend_Auth::getInstance()->authenticate($authAdapter);
         //$this->_helper->logger->debug ( $result );
         switch ($result->getCode()) {
             case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
             case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
                 break;
             case Zend_Auth_Result::SUCCESS:
                 Zend_Session::regenerateId();
                 preg_match('/[^.]+\\.[^.]+$/', $_SERVER['SERVER_NAME'], $domain);
                 setcookie(self::AUTH_SID, Zend_Session::getId(), time() + 1200, self::AUTH_PATH, ".{$domain['0']}", null, true);
                 $last = time();
                 setcookie('last', $last, null, '/', ".{$domain['0']}", null, true);
                 $lastLogin = new Zend_Session_Namespace('last');
                 $lastLogin->lastLogin = $last;
                 $lastLogin->setExpirationHops(1, null, 1);
                 $authAcl = new Zend_Session_Namespace('authAcl');
                 $authAcl->authId = $loginForm->getValue('username');
                 $this->_helper->redirector('index', 'index');
                 return;
             default:
                 /** do stuff for other failure **/
                 break;
         }
     }
     $this->view->form = $loginForm;
 }
 public function indexAction()
 {
     //$this->_helper->layout ()->disableLayout ();
     $auth = Zend_Auth::getInstance();
     $authContent = $auth->getStorage()->read();
     $authAcl = new Zend_Session_Namespace('authAcl');
     $guestID = Authz_Resource_Acl_Guest::GUEST_ID;
     if (is_array($authContent) and $authContent['identity'] != $guestID) {
         return;
     }
     $loginForm = new Auth_Form_Auth_Login($_POST);
     $authAdapter = null;
     if ($this->getRequest()->isPost() and $loginForm->isValid($_POST)) {
         self::login($loginForm->getValue('username'), $loginForm->getValue('password'));
     }
     $this->view->form = $loginForm;
 }