From 780367c1601998bf832652d7f08b15a43d1ccb37 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq.com> Date: Thu, 2 Jul 2026 11:15:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=AA=8C=E8=AF=81=E7=A0=812?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/admin/Login.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controller/admin/Login.php b/app/controller/admin/Login.php index 5077958..5388df4 100644 --- a/app/controller/admin/Login.php +++ b/app/controller/admin/Login.php @@ -96,8 +96,12 @@ class Login extends Base { return $this->buildFailed(ReturnCode::LOGIN_ERROR, '用户已被封禁,请联系管理员'); } } else { - $this->setFailKey($username); - return $this->buildFailed(ReturnCode::LOGIN_ERROR, '用户名密码不正确'); + $count = $this->setFailKey($username); + return $this->buildFailed( + ReturnCode::LOGIN_ERROR, + '用户名密码不正确', + ['need_captcha' => $count >= $this->captchaThreshold] + ); } $userInfo['access'] = $this->getAccess($userInfo['id']); $userInfo['menu'] = $this->getAccessMenuData($userInfo['id']); @@ -221,15 +225,13 @@ class Login extends Base { ]); } - protected function captchaCheck($username, $captchaToken, $captchaInput) - { - } - protected function setFailKey($username) { $failKey = "login:fail:{$username}"; $failCount = (int) Cache::get($failKey, 0); - Cache::set($failKey, $failCount + 1, $this->lockMinutes * 60); + $failCount += 1; + Cache::set($failKey, $failCount, $this->lockMinutes * 60); + return $failCount; } /**