From a812cd8d0a5df7f96b8b9010072ebe40b799594d Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Mon, 21 Aug 2023 11:28:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=99=90=E5=88=B6=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E9=94=99=E8=AF=AF=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/library/Auth.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/application/common/library/Auth.php b/application/common/library/Auth.php index de69d3b..f5eb20e 100644 --- a/application/common/library/Auth.php +++ b/application/common/library/Auth.php @@ -6,6 +6,7 @@ use app\common\model\User; use app\common\model\UserRule; use fast\Random; use think\Config; +use think\Cookie; use think\Db; use think\Exception; use think\Hook; @@ -207,8 +208,16 @@ class Auth $this->setError('Account is locked'); return false; } + $loginError = Cookie::get($account); + print_r($loginError); + if ($loginError && $loginError>=5) { + $this->setError(__('登录错误次数过多,请5分钟后再登录'));; + return false; + } if ($user->password != $this->getEncryptPassword($password, $user->salt)) { - $this->setError('Password is incorrect'); + $loginError = $loginError?$loginError+1:1; + Cookie::set($account,$loginError,60*5); + $this->setError("登录错误".$loginError."次,5次后将被限制登录5分钟"); return false; }