Ejemplo n.º 1
0
 /**
  * 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
 }