Esempio n. 1
0
 public function beforeAction()
 {
     parent::beforeAction();
     Wk_Request::startSession(WAKA_DOMAIN);
     if (isset($_SESSION['user'])) {
         $this->curUser = $_SESSION['user'];
     }
     if (isset($this->curUser)) {
         Wk::app()->user = new Wk_WebUser();
         Wk::app()->user->userid = $this->curUser->id;
         Wk::app()->user->utoken = "";
     }
     if (isset($this->curUser)) {
         WkAdminUserService::getInstance()->setLoginCookie($this->curUser);
     } else {
         unset($_COOKIE['WAKAUID']);
         unset($_COOKIE['WAKAUMB']);
         setcookie('WAKAUID', '', time() - 3600, '/', WAKA_DOMAIN);
         setcookie('WAKAUMB', '', time() - 3600, '/', WAKA_DOMAIN);
     }
     $access = $this->access();
     if (!empty($access['?']) && in_array($this->actionName, $access['?'])) {
         if ($this->isLogin()) {
             throw new Wk_Exception('', TErrorConstants::E_LOGIN);
         }
     } elseif (!empty($access['*']) && in_array($this->actionName, $access['*'])) {
     } elseif ($this->isGuest()) {
         throw new Wk_Exception('', TErrorConstants::E_NOT_LOGIN);
     }
 }
Esempio n. 2
0
 /**
  * 管理员注册(内部接口)
  * @apiMethod post
  * @apiParam string mobile 手机号
  * @apiParam string password 密码
  * @apiParam string rePassword 密码确认
  * @return array
  * @throws Wk_Exception
  */
 public function submitAdminRegisterAction()
 {
     $mobile = Wk_Request::getRequestString("mobile", null, false);
     $password = Wk_Request::getRequestString("password", null, false);
     $rePassword = Wk_Request::getRequestString("rePassword", null, false);
     if ($password != $rePassword) {
         throw new Wk_Exception("管理员注册两次密码不一致,请重新输入", -1);
     }
     $userid = WkAdminUserService::getInstance()->submitAdminUserRegister($mobile, $password);
     return ['userid' => $userid];
 }