Ejemplo 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);
     }
 }
Ejemplo n.º 2
0
 public function beforeAction()
 {
     parent::beforeAction();
     $this->authWeb();
     $webUser = new Wk_WebUser();
     if (!empty($this->curUser)) {
         $webUser->utoken = $this->curToken;
         $webUser->userid = $this->curUser->userid;
     }
     Wk::app()->user = $webUser;
     $access = $this->access();
     if (!empty($access['@']) && in_array($this->actionName, $access['@']) && !$this->isLogin()) {
         throw new Wk_Exception('', TErrorConstants::E_NOT_LOGIN);
     }
     if (!empty($access['?']) && in_array($this->actionName, $access['?']) && $this->isLogin()) {
         throw new Wk_Exception('', TErrorConstants::E_LOGIN);
     }
     // deal with wx token leak bug
     //        if ($this->getClientType() == 'wx' && AppIdentity::getInstance()->isApp()) {
     //            unset($_SESSION['appParam']);
     //            AppIdentity::getInstance()->init('','tweb','','','');
     //            $_SESSION['appParam'] = AppIdentity::getInstance()->toParamArr();
     //        }
 }