diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index fe560fb3..695f967b 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -15,8 +15,7 @@ use think\Validate; */ class Index extends Backend { - - protected $noNeedLogin = ['login']; + protected $noNeedLogin = ['login', 'logout']; protected $noNeedRight = ['index', 'logout']; protected $layout = ''; @@ -127,6 +126,12 @@ class Index extends Backend */ public function logout() { + //先判断用户身份是否有效 + $res = $this->auth->getUserInfo(); + if (!$res){ + Hook::listen("admin_logout_after", $this->request); + $this->success(__('Logout successful'), 'index/login'); + } if ($this->request->isPost()) { $this->auth->logout(); Hook::listen("admin_logout_after", $this->request);