Пример #1
0
 public function autenticarAction()
 {
     $this->dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter');
     @($usuarioactual = $this->request->getPost('username'));
     @($usuariopassword = $this->request->getPost('password'));
     $this->login = new LoginService($this->dbAdapter, 'comisionista', 'usr', 'psw');
     if (!$this->request->isPost()) {
         $this->redirect()->toRoute('comisionista', array('controller' => 'index'));
     }
     $form = new Login("login");
     $form->setInputFilter(new LoginValidator());
     $data = $this->request->getPost();
     $form->setData($data);
     if (!$form->isValid()) {
         $modelView = new ViewModel(array('form' => $form));
         $modelView->setTemplate('comisionista/index/index');
         $this->layout('layout/comisionistas');
         return $modelView;
     }
     $values = $form->getData();
     $us = $values['username'];
     $clave = $values['password'];
     try {
         $this->login->setMessage('El nombre de Usuario y Password no coinciden.', LoginService::NOT_IDENTITY);
         $this->login->setMessage('La contrasena ingresada es incorrecta. Inténtelo de nuevo.', LoginService::INVALID_CREDENTIAL);
         $this->login->setMessage('Los campos de Usuario y Password no puedendejarse en blanco.', LoginService::INVALID_LOGIN);
         $this->login->login($us, $clave);
         $this->messenger->message = "Login Correcto!!!";
         $this->messenger->value = true;
         $this->layout()->messenger = $this->messenger;
         $session = new Container('comisionista');
         $session->nombre = $us;
         return $this->forward()->dispatch('Comisionista\\Controller\\Index', array('action' => 'index'));
     } catch (\Exception $e) {
         $this->messenger->message = $e->getMessage();
         $this->messenger->value = false;
         $this->layout()->messenger = $this->messenger;
         return $this->forward()->dispatch('Comisionista\\Controller\\Index', array('action' => 'index'));
     }
     return $modelView;
 }
Пример #2
0
 public function loginAction()
 {
     $this->dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter');
     @($us = $this->request->getPost('username'));
     @($password = $this->request->getPost('password'));
     $this->login = new LoginService($this->dbAdapter, 'usuario', 'us', 'contrasena');
     if (!$this->request->isPost()) {
         $this->redirect()->toUrl($this->basePath() . '/usuario/');
     }
     $form = new Login("login");
     $form->setInputFilter(new LoginValidator());
     $data = $this->request->getPost();
     $form->setData($data);
     if (!$form->isValid()) {
         $modelView = new ViewModel(array('form' => $form, 'usuario' => $us));
         $modelView->setTemplate('micrositio/html/clientes');
         $this->layout('layout/simple');
         return $modelView;
     }
     $values = $form->getData();
     $us = $values['username'];
     $pass = $values['password'];
     try {
         $this->login->setMessage('El nombre de Usuario y Password no coinciden.', LoginService::NOT_IDENTITY);
         $this->login->setMessage('La contrasena ingresada es incorrecta. Inténtelo de nuevo.', LoginService::INVALID_CREDENTIAL);
         $this->login->setMessage('Los campos de Usuario y Password no pueden dejarse en blanco.', LoginService::INVALID_LOGIN);
         $this->login->login($us, $pass);
         $this->messenger->message = "Login Correcto!!!";
         $this->messenger->value = true;
         $this->layout()->messenger = $this->messenger;
         $session2 = new Container('usuario');
         $session2->us = $us;
         return $this->forward()->dispatch('Micrositio\\Controller\\Html', array('action' => 'home', 'email' => $email, 'password' => $password));
     } catch (\Exception $e) {
         $this->messenger->message = $e->getMessage();
         $this->messenger->value = false;
         $this->layout()->messenger = $this->messenger;
         return $this->forward()->dispatch('Micrositio\\Controller\\Html', array('action' => 'clientes', 'email' => $email, 'password' => $password));
     }
     return $modelView;
 }