public function loginAction() { $this->_helper->layout->setLayout('login'); $form = new App_Form_Auth_LoginForm(); $form->setAction('/auth/login'); $this->view->formResponse = ''; if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { $formData = $this->_getFormData(); $authAdapter = $this->_getAuthAdapter($formData); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); if (!$result->isValid()) { $this->view->message = 'Sorry, there was a problem with your submission. Please check the following:'; } else { $data = $authAdapter->getResultRowObject(null, 'password'); $visits = new App_Model_Users(); $visits->addVisit($data->id); $auth->getStorage()->write($data); $this->_redirect($this->_redirectUrl); } } else { // ensure that the Auth adapter is cleared $auth = Zend_Auth::getInstance(); $auth->clearIdentity(); $this->view->formResponse = 'Sorry, there was a problem with your submission. Please check the following:'; $form->populate($_POST); } } $this->view->form = $form; }