public function indexAction()
 {
     if ($this->auth->hasIdentity()) {
         $this->_helper->redirector('index', 'index');
     }
     $translator = Zend_Registry::get('container')->getService('translator');
     $form = new Application_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $values = $form->getValues();
         $adapter = $this->_helper->service('auth.adapter');
         $adapter->setEmail($values['email'])->setPassword($values['password']);
         $result = $this->auth->authenticate($adapter);
         if ($result->getCode() == Zend_Auth_Result::SUCCESS) {
             $expire = null;
             if (!empty($values['remember_me'])) {
                 // set expire to 10 years in the future
                 $expire = time() + 10 * 365 * 24 * 60 * 60;
             }
             setcookie('NO_CACHE', '1', $expire, '/', '.' . $this->extractDomain($_SERVER['HTTP_HOST']));
             if (isset($values['_target_path'])) {
                 $this->_helper->redirector->gotoUrl($values['_target_path']);
             }
             $this->_helper->redirector('index', 'dashboard');
         } else {
             $form->addError($translator->trans("Invalid credentials"));
         }
     }
     $this->view->form = $form;
 }
Beispiel #2
0
 public function indexAction()
 {
     if ($this->auth->hasIdentity()) {
         $this->_helper->redirector('index', 'index');
     }
     $form = new Application_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $values = $form->getValues();
         $adapter = $this->_helper->service('auth.adapter');
         $adapter->setEmail($values['email'])->setPassword($values['password']);
         $result = $this->auth->authenticate($adapter);
         if ($result->getCode() == Zend_Auth_Result::SUCCESS) {
             $this->_helper->redirector('index', 'dashboard');
         } else {
             $form->addError($this->view->translate("Invalid credentials"));
         }
     }
     $this->view->form = $form;
 }