IsInWhiteList(); if (!$isWhiteMethod) { if (!Session::has("kefuId", "kefu")) { $token = Request::instance()->param('token', ''); $token_type = Request::instance()->param('token_type', 'kefu'); if ($token) { try { if ($token_type == "kefu") { $jwtService = new JwtService("kefu"); $kefuId = $jwtService->parseToken($token); $jwtService->verifyToken(); } else { $jwtService = new JwtService("wap"); $uid = $jwtService->parseToken($token); $jwtService->verifyToken(); $kefuInfo = (new KefuModel)->where('uid', $uid)->find(); $kefuId = $kefuInfo->id; } Session::set("kefuId", $kefuId, "kefu"); } catch (Exception $e) { return $this->redirect('dashboard/login'); } } else { return $this->redirect('dashboard/login'); } } try { $kefuId = Session::get("kefuId", "kefu"); $kefuInfo = KefuModel::get($kefuId); if (!$kefuInfo) exception("请登录!"); if (!$kefuInfo['status']) exception("该账号已被禁用!"); $site_name = SystemConfigService::get('site_name'); $kefuInfo['site_name'] = $site_name; $this->kefuId = $kefuId; $this->kefuInfo = $kefuInfo; $this->assign("kefuId", $kefuId); $this->assign("kefuInfo", $kefuInfo); } catch (\Exception $e) { $errorMsg = $e->getMessage(); $url = 'dashboard/login?error_msg=' . $errorMsg; return $this->redirect($url); } } } protected function IsInWhiteList() { list($module, $controller, $action, $className) = $this->getCurrentController(); if (method_exists($className, 'WhiteList')) { $whitelist = $className::WhiteList(); if (!is_array($whitelist)) return false; foreach ($whitelist as $item) { if (strtolower($module . '\\' . $controller . '\\' . $item) == strtolower($module . '\\' . $controller . '\\' . $action)) { return true; } } } return false; } protected function getCurrentController() { $module = $this->request->module(); $controller = $this->request->controller(); $action = $this->request->action(); if (strstr($controller, '.')) $controllerv1 = str_replace('.', '\\', $controller); else $controllerv1 = $controller; $className = 'app\\' . $module . '\\controller\\' . $controllerv1; return [$module, $controller, $action, $className]; } }