public function indexAction() { $form = new Admin_Form_Login(); $this->view->form = $form; if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { $adapter = new Rph_Auth_Adapter($form->getValue('login'), sha1($form->getValue('senha'))); $result = Zend_Auth::getInstance()->authenticate($adapter); if (Zend_Auth::getInstance()->hasIdentity()) { return $this->_helper->redirector('index', 'index', 'admin'); } else { $this->_helper->FlashMessenger(implode(' ', $result->getMessages())); } } else { $form->populate($formData); } } }
public function loginAction() { $this->_helper->layout()->setLayout("borrower/layout_login"); $oFormLogin = new Admin_Form_Login(); $oFacebook = new Facebook_Facebook(); if (!$this->_oAuth->hasIdentity() && $oFacebook->getUser()) { $oFacebook->destroySession(); } $aPostData = array(); if ($this->_request->isPost()) { $aPostData = $this->_request->getPost(); if ($oFormLogin->isValid($aPostData)) { $sEmailAddress = $oFormLogin->getValue("user_email_address") != "" ? $oFormLogin->getValue("user_email_address") : ""; $sPassword = $oFormLogin->getValue("user_password"); $oResult = $this->_oAuth->auth($sEmailAddress, $sPassword); if ($oResult->isValid()) { $this->_redirect("/admin"); } } } $oFormLogin->populate($aPostData); $this->view->oFormLogin = $oFormLogin; }