public function indexAction()
 {
     $this->_helper->layout->setLayout('login');
     $form = new Login_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             if ($this->_process($form->getValues())) {
                 // We're authenticated! Redirect to the home page
                 // echo $data["0"]["acl_roles_id"]."roleeeee production";
                 //                    $this->gpms = new Zend_Session_Namespace('gpms');
                 //                    $this->gpms->role_application=$this->gpms->storage->role_id;
                 //                     Zend_Debug::dump($_SESSION,"index");
                 //                    die();
                 // $_SESSION['gpms']['role_application']=$_SESSION['gpms']['storage']->role_id;
                 //setup $_session
                 $this->production = new Zend_Session_Namespace('production');
                 //begin in production
                 $this->production->id = null;
                 $this->production->name = null;
                 $this->production->activity_id = null;
                 $this->production->activity_name = null;
                 $this->gpms = new Zend_Session_Namespace('gpms');
                 $this->gpms->storage->out_production = 0;
                 $this->gpms->role_application = $this->gpms->storage->role_id;
                 $_SESSION["company"]["id"] = null;
                 $this->_helper->redirector('index', 'index', 'default');
             }
         } else {
             $this->_helper->redirector('error', 'error', 'login');
         }
     }
     $this->view->form = $form;
 }
 public function indexAction()
 {
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_redirect('admin/index');
     }
     // Create form login
     $form = new Login_Form_Login();
     $request = $this->getRequest();
     // Is post
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             // Get values from form
             $user = $form->getValue('username');
             $password = $form->getValue('password');
             $authAdapter = $this->getAuthAdapter();
             $authAdapter->setIdentity($user)->setCredential($password);
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($authAdapter);
             # is the user a valid one?
             if ($result->isValid()) {
                 # all info about this user from the login table
                 # ommit only the password, we don't need that
                 $userInfo = $authAdapter->getResultRowObject(null, 'password');
                 # the default storage is a session with namespace Zend_Auth
                 $authStorage = $auth->getStorage();
                 $authStorage->write($userInfo);
                 $this->_redirect('admin/index');
             } else {
                 $errorMessage = "Wrong username or password provided. Please try again.";
             }
         }
     }
     $errorMessage = "";
     // View
     $this->view->title = 'Login';
     $this->view->form = $form;
 }