From b1cb5a798ed4b86d4d25a5475acf6e6baca942fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E9=A3=9E?= Date: Fri, 28 Oct 2022 08:16:50 +0000 Subject: [PATCH] * Fix bug of unauthorized users. --- framework/base/control.class.php | 20 ++++++++++++++++++++ framework/base/router.class.php | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/framework/base/control.class.php b/framework/base/control.class.php index 1576843b29..2e5f072568 100644 --- a/framework/base/control.class.php +++ b/framework/base/control.class.php @@ -208,6 +208,26 @@ class baseControl $this->setMethodName($methodName); $this->loadModel($this->moduleName, $appName); + /** + * 检查用户是否登录,如果没有登录,跳转到登录页面。 + * Check the user has logon or not, if not, goto the login page. + */ + if(empty($this->app->user) && !$this->loadModel('common')->isOpenMethod($this->moduleName, $this->methodName)) + { + $uri = $this->app->getURI(true); + if($this->moduleName == 'message' and $this->methodName == 'ajaxgetmessage') + { + $uri = helper::createLink('my'); + } + elseif(helper::isAjaxRequest()) + { + die(json_encode(array('result' => false, 'message' => $this->lang->error->loginTimeout))); + } + + $referer = helper::safe64Encode($uri); + die(js::locate(helper::createLink('user', 'login', "referer=$referer"))); + } + /** * 如果客户端是手机的话,视图文件增加m.前缀。 * If the clent is mobile, add m. as prefix for view file. diff --git a/framework/base/router.class.php b/framework/base/router.class.php index 612b5ef0b9..11cb3221df 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -1555,8 +1555,8 @@ class baseRouter { if($this->config->framework->filterParam == 2) { - $_GET = validater::filterParam($_GET, 'get'); - $_COOKIE = validater::filterParam($_COOKIE, 'cookie'); + $_GET = validater::filterParam($_GET, 'get'); + $_COOKIE = validater::filterParam($_COOKIE, 'cookie'); } } return true;