public function indexAction() { $form = new Admin_Form_LoginForm(); $request = $this->getRequest(); if ($request->isPost()) { if ($form->isValid($request->getPost())) { // do something here to log in if ($this->_process($form->getValues())) { // We're authenticated! Redirect to the home page $this->_helper->redirector("index", "index"); //$this->_helper->redirector("action","controller","module"); } } } $this->view->form = $form; }
/** * Login action */ public function dologinAction() { $user = new AdminUser(); $request = $this->getRequest(); $translation = Shineisp_Registry::getInstance()->Zend_Translate; // Get our form and validate it $form = new Admin_Form_LoginForm(array('action' => '/admin/login/dologin', 'method' => 'post')); // Invalid entries if ($form->isValid($request->getPost())) { if ($this->getRequest()->isPost()) { $result = AdminUser::fastlogin($this->getRequest()->getParam("email"), $this->getRequest()->getParam("password"), $this->getRequest()->getParam("rememberme")); switch ($result->getCode()) { case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND: /** do stuff for nonexistent identity **/ Shineisp_Commons_Utilities::log("Login: User not found.", "login.log"); $this->view->message = $translation->translate('User not found.'); break; case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID: /** do stuff for invalid credential **/ Shineisp_Commons_Utilities::log("Login: The email address or password is incorrect. please try again.", "login.log"); $this->view->message = $translation->translate('The email address or password is incorrect. please try again.'); break; case Zend_Auth_Result::SUCCESS: /** do stuff for successful authentication **/ Shineisp_Commons_Utilities::log("Login: The User has been authenticated successfully.", "login.log"); AdminUser::updateLog($this->getRequest()->getParam("email")); $this->_helper->redirector('index', 'index', 'admin'); break; case Zend_Auth_Result::FAILURE: /** do stuff for other failure **/ Shineisp_Commons_Utilities::log("Login: There was a problem during the login process.", "login.log"); $this->view->message = $translation->translate('There was a problem during the login process.'); break; } } else { Shineisp_Commons_Utilities::log("Login: Invalid Post Request.", "login.log"); $this->view->message = $translation->translate('Invalid Post Request.'); } } //Show the login form $this->view->loginform = $form; return $this->render('index'); // re-render the login form }
public function mainAction() { if (Admin_View_Helper_Authentication::isUserAdmin()) { $form = new Admin_Form_ChangePasswordForm(); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $data = $this->_user->changePassword($formData); if ($data['status'] == 0) { $this->view->error = $data['message']; } else { $this->view->message = $data['message']; } } else { $form->populate($formData); } } $this->view->form = $form; } else { $form = new Admin_Form_LoginForm(); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $data = $this->_user->login($formData); if ($data['status'] == 0) { $this->view->error = "Login failed"; } else { $this->redirect("enlighten/panel/main/"); } } else { $form->populate($formData); } } $this->view->form = $form; } }