From a481ba29593576df83265b2f8f73451f89803ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Mon, 18 Apr 2022 11:26:21 +0800 Subject: [PATCH] * adjust for check priv. --- module/common/model.php | 63 ++++++++++++++++++++++------------------ module/index/js/index.js | 2 +- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/module/common/model.php b/module/common/model.php index 026d663745..31041a95e0 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -360,7 +360,7 @@ class commonModel extends model { echo js::locate($denyLink); } - die; + helper::end(); } /** @@ -2194,36 +2194,43 @@ EOD; */ public function checkPriv() { - $module = $this->app->getModuleName(); - $method = $this->app->getMethodName(); - if($this->app->isFlow) + try { - $module = $this->app->rawModule; - $method = $this->app->rawMethod; + $module = $this->app->getModuleName(); + $method = $this->app->getMethodName(); + if($this->app->isFlow) + { + $module = $this->app->rawModule; + $method = $this->app->rawMethod; + } + + $beforeValidMethods = array( + 'user' => array('deny', 'logout'), + 'my' => array('changepassword'), + 'message' => array('ajaxgetmessage'), + ); + if(!empty($this->app->user->modifyPassword) and (!isset($beforeValidMethods[$module]) or !in_array($method, $beforeValidMethods[$module]))) return print(js::locate(helper::createLink('my', 'changepassword', '', '', true))); + if($this->isOpenMethod($module, $method)) return true; + if(!$this->loadModel('user')->isLogon() and $this->server->php_auth_user) $this->user->identifyByPhpAuth(); + if(!$this->loadModel('user')->isLogon() and $this->cookie->za) $this->user->identifyByCookie(); + + if(isset($this->app->user)) + { + if(in_array($module, $this->config->programPriv->waterfall) and $this->app->tab == 'project') return true; + + $this->app->user = $this->session->user; + if(!commonModel::hasPriv($module, $method)) $this->deny($module, $method); + } + else + { + $referer = helper::safe64Encode($this->app->getURI(true)); + print(js::locate(helper::createLink('user', 'login', "referer=$referer"))); + helper::end(); + } } - - $beforeValidMethods = array( - 'user' => array('deny', 'logout'), - 'my' => array('changepassword'), - 'message' => array('ajaxgetmessage'), - ); - if(!empty($this->app->user->modifyPassword) and (!isset($beforeValidMethods[$module]) or !in_array($method, $beforeValidMethods[$module]))) return print(js::locate(helper::createLink('my', 'changepassword', '', '', true))); - if($this->isOpenMethod($module, $method)) return true; - if(!$this->loadModel('user')->isLogon() and $this->server->php_auth_user) $this->user->identifyByPhpAuth(); - if(!$this->loadModel('user')->isLogon() and $this->cookie->za) $this->user->identifyByCookie(); - - if(isset($this->app->user)) + catch(EndResponseException $endResponseException) { - if(in_array($module, $this->config->programPriv->waterfall) and $this->app->tab == 'project') return true; - - $this->app->user = $this->session->user; - if(!commonModel::hasPriv($module, $method)) $this->deny($module, $method); - } - else - { - $referer = helper::safe64Encode($this->app->getURI(true)); - print(js::locate(helper::createLink('user', 'login', "referer=$referer"))); - helper::end(); + echo $endResponseException->getContent(); } } diff --git a/module/index/js/index.js b/module/index/js/index.js index e7746c1d43..b1aa8bbce9 100644 --- a/module/index/js/index.js +++ b/module/index/js/index.js @@ -194,7 +194,7 @@ else { appCode = getAppCodeFromUrl(url); - if(!appCode) return false; + if(!appCode) return openTab('my'); } }