/** * User can invited or sign-up * * @return void */ public function postAction() { // Getting parameters $params = $this->_helper->param(); $response = $this->_helper->response(true); // Check username dublicate $user = Doctrine_Core::getTable('Model_Entity_User')->findOneByuserName(array($params['userName'])); if (is_object($user)) { $response->setSuccess(false)->addNotification(Kebab_Notification::ERR, 'This username is already at system.')->getResponse(); } $user = Kebab_Model_User::activate($params['userName'], $params['password'], $params['fullName'], $params['activationKey']); Kebab_Authentication::signIn($user->userName, $params['password']); $response->getResponse(); }
/** * Login * * @return void */ public function postAction() { // Get params $userName = $this->_request->getParam('userName'); $password = $this->_request->getParam('password'); $rememberMe = $this->_request->getParam('rememberMe'); // Check rememberMe checkbox if (is_null($rememberMe)) { Zend_Session::forgetMe(); } if ($this->getRequest()->isPost() && Kebab_Validation_UserName::isValid($userName) && Kebab_Validation_Password::isValid($password)) { $hasIdentity = Kebab_Authentication::signIn($userName, $password, !is_null($rememberMe)); if ($hasIdentity) { $this->_helper->response(true, 200)->getResponse(); } else { $this->_helper->response()->addNotification(Kebab_Notification::ERR, 'Please check your user name and password!')->getResponse(); } } else { $this->_helper->response()->getResponse(); } }
public function putAction() { // Param $params = $this->_helper->param(); $userSessionId = Zend_Auth::getInstance()->getIdentity()->id; // Validation $fullName = $params['fullName']; $email = $params['email']; $language = $params['language']; //KBBTODO move DQL to model class Doctrine_Manager::connection()->beginTransaction(); try { $userExistsWithEmail = Doctrine_Query::create()->from('Model_Entity_User user')->where('user.email = ?', $email)->andWhere('user.id != ?', $userSessionId)->useQueryCache(Kebab_Cache_Query::isEnable())->fetchOne(); if (is_object($userExistsWithEmail)) { // Another User exists with entered email $this->_helper->response(false, 201)->set('email', 'Another User with email exists.')->getResponse(); } // DQL $profile = new Model_Entity_User(); $profile->assignIdentifier($userSessionId); $profile->fullName = $fullName; $profile->email = $email; $profile->language = $language; $profile->save(); Doctrine_Manager::connection()->commit(); // Reset Session Kebab_Authentication::signOut(); Kebab_Authentication::signIn($profile->userName, $profile->password, false, false); // Response $this->_helper->response(true, 201)->addData(array('userName' => $profile->userName, 'fullName' => $profile->fullName))->getResponse(); unset($profile); } catch (Zend_Exception $e) { Doctrine_Manager::connection()->rollback(); throw $e; } catch (Doctrine_Exception $e) { Doctrine_Manager::connection()->rollback(); throw $e; } }