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; } /**