コード例 #1
0
 /**
  * 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();
 }
コード例 #2
0
 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;
     }
 }
コード例 #3
0
 /**
  * Logout action
  *
  * @return void
  */
 public function deleteAction()
 {
     Kebab_Authentication::signOut();
     $this->_helper->response(true, 204)->getResponse();
 }