public function postAction() { if ($datas = Zend_Json::decode($this->getRequest()->getRawBody())) { try { if (empty($datas['email']) or empty($datas['password'])) { throw new Exception($this->_('Authentication failed. Please check your email and/or your password')); } $customer = new Customer_Model_Customer(); $customer->find(array('email' => $datas['email'], 'app_id' => $this->getApplication()->getId())); $password = $datas['password']; if (!$customer->getId() or !$customer->authenticate($password)) { throw new Exception($this->_('Authentication failed. Please check your email and/or your password')); } if (!$customer->getAppId()) { $customer->setAppId($this->getApplication()->getId())->save(); } $this->getSession()->resetInstance()->setCustomer($customer); $html = array('success' => 1, 'customer_id' => $customer->getId(), 'can_access_locked_features' => $customer->canAccessLockedFeatures()); } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($html); } }