From f24de31a923ff8c9b499406ab53d11429d995d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Thu, 15 Jan 2026 05:26:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/library/Auth.php | 16 ++++++++++------ application/common/controller/adminApi.php | 4 +++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/application/admin/library/Auth.php b/application/admin/library/Auth.php index ce07f35a..d3452e44 100644 --- a/application/admin/library/Auth.php +++ b/application/admin/library/Auth.php @@ -229,6 +229,7 @@ class Auth extends \fast\Auth if ($this->logined) { return true; } + $admin = Session::get('admin'); if (!$admin) { $admin = Cache::get("admin_" . $token); @@ -239,6 +240,7 @@ class Auth extends \fast\Auth // Session::set("admin.safecode", $this->getEncryptSafecode($admin)); } } + if (!$admin) { return false; } @@ -246,6 +248,7 @@ class Auth extends \fast\Auth if (!$my) { return false; } + //校验安全码,可用于判断关键信息发生了变更需要重新登录 // if (!isset($admin['safecode']) || $this->getEncryptSafecode($my) !== $admin['safecode']) { // $this->logout(); @@ -259,12 +262,13 @@ class Auth extends \fast\Auth } } //判断管理员IP是否变动 - if (Config::get('fastadmin.loginip_check')) { - if (!isset($admin['loginip']) || $admin['loginip'] != request()->ip()) { - $this->logout(); - return false; - } - } +// if (Config::get('fastadmin.loginip_check')) { +// if (!isset($admin['loginip']) || $admin['loginip'] != request()->ip()) { +// $this->logout(); +// return false; +// } +// +// } $this->logined = true; return true; } diff --git a/application/common/controller/adminApi.php b/application/common/controller/adminApi.php index 93eebe43..08316e72 100644 --- a/application/common/controller/adminApi.php +++ b/application/common/controller/adminApi.php @@ -142,7 +142,9 @@ class adminApi extends Controller //通过头部信息获取authorization0 $token = $this->request->server('HTTP_AUTHORIZATION', $this->request->request('token', \think\Cookie::get('token'))); //检测是否登录 - if (!$this->auth->isLogin($token)) { +// if (!$this->auth->isLogin($token)) { + $auth = new Auth ; + if (!$auth->isLogin($token)) { Hook::listen('admin_nologin', $this); $url = Session::get('referer'); $url = $url ? $url : $this->request->url();