Ejemplo n.º 1
0
 public function loginAction()
 {
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_redirect('/');
     }
     $request = $this->getRequest();
     $form = new Application_Form_LoginForm();
     if ($request->isPost() && $form->isValid($this->_request->getPost())) {
         $adapter = $this->getAdapter();
         $email = $form->getValue('email');
         $password = $form->getValue('password');
         $adapter->setIdentity($email)->setCredential($password);
         $auth = Zend_Auth::getInstance();
         $result = $auth->authenticate($adapter);
         if ($result->isValid()) {
             $identity = $adapter->getResultRowObject();
             $storage = $auth->getStorage();
             $storage->write($identity);
             $this->_redirect('/');
         } else {
             $this->view->errorMessage = "Username or password is wrong";
         }
     }
     $this->view->form = $form;
 }
Ejemplo n.º 2
0
 public function indexAction()
 {
     //$this->_helper->layout()->setLayout('notlogged');
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_redirect('/account/profile');
     }
     $loginform = new Application_Form_LoginForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($loginform->isValid($request->getPost())) {
             $email = $loginform->getValue('email');
             $password = $loginform->getValue('password');
             $result = new Application_Model_Base();
             $result->authUser($email, $password);
             if ($result == true) {
                 $this->_redirect('/things');
             } else {
                 $errorMessage = "Wrong username or password provided. Please try again.";
             }
         }
     }
     //	$this->view->errorMessage = $errorMessage;
     $this->view->loginform = $loginform;
 }