public function postAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { $this->getSession()->resetInstance(); try { if (empty($data['email']) or empty($data['password'])) { throw new Exception($this->_('Authentication failed. Please check your email and/or your password')); } $user = new Backoffice_Model_User(); $user->find($data['email'], 'email'); if ($user->authenticate($data['password'])) { $this->getSession()->setBackofficeUser($user); } $notification = new Backoffice_Model_Notification(); $notification->update(); if (!$this->getSession()->isLoggedIn()) { throw new Exception($this->_('Authentication failed. Please check your email and/or your password')); } $data = array("success" => 1, "user" => $user->getData()); } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }
public function loginpostAction() { if ($data = $this->getRequest()->getPost()) { $this->getSession()->resetInstance(); try { if (empty($data['email']) or empty($data['password'])) { throw new Exception($this->_('Authentication failed. Please check your email and/or your password')); } $user = new Backoffice_Model_User(); $user->find($data['email'], 'email'); if ($user->authenticate($data['password'])) { $this->getSession()->setBackofficeUser($user); } if (!$this->getSession()->isLoggedIn()) { throw new Exception($this->_('Authentication failed. Please check your email and/or your password')); } } catch (Exception $e) { $this->getSession()->addError($e->getMessage()); } } $this->_redirect('backoffice'); return $this; }