From c77e1801ace11ea23138c86c528619760d565acf Mon Sep 17 00:00:00 2001 From: koogua Date: Wed, 23 Mar 2022 09:52:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=AA=8C=E8=AF=81=E7=A0=81?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E5=90=8E=E5=8F=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Home/Services/Account.php | 12 ++++++++++-- app/Services/Logic/Verify/MailCode.php | 9 +++++++-- app/Services/Logic/Verify/SmsCode.php | 9 +++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/Http/Home/Services/Account.php b/app/Http/Home/Services/Account.php index 929c30ac..8516bcad 100644 --- a/app/Http/Home/Services/Account.php +++ b/app/Http/Home/Services/Account.php @@ -53,9 +53,17 @@ class Account extends Service $validator->checkIfAllowLogin($user); - $validator = new CaptchaValidator(); + $captcha = $this->getSettings('captcha'); - $validator->checkCode($post['ticket'], $post['rand']); + /** + * 验证码是一次性的,放到最后检查,减少第三方调用 + */ + if ($captcha['enabled'] == 1) { + + $validator = new CaptchaValidator(); + + $validator->checkCode($post['ticket'], $post['rand']); + } $this->auth->saveAuthInfo($user); diff --git a/app/Services/Logic/Verify/MailCode.php b/app/Services/Logic/Verify/MailCode.php index 9a04d1dc..d3cb7768 100644 --- a/app/Services/Logic/Verify/MailCode.php +++ b/app/Services/Logic/Verify/MailCode.php @@ -23,9 +23,14 @@ class MailCode extends LogicService $post['email'] = $validator->checkEmail($post['email']); - $validator = new CaptchaValidator(); + $captcha = $this->getSettings('captcha'); - $validator->checkCode($post['ticket'], $post['rand']); + if ($captcha['enabled'] == 1) { + + $validator = new CaptchaValidator(); + + $validator->checkCode($post['ticket'], $post['rand']); + } $service = new MailVerifyService(); diff --git a/app/Services/Logic/Verify/SmsCode.php b/app/Services/Logic/Verify/SmsCode.php index c97dbd56..adcbb080 100644 --- a/app/Services/Logic/Verify/SmsCode.php +++ b/app/Services/Logic/Verify/SmsCode.php @@ -23,9 +23,14 @@ class SmsCode extends LogicService $post['phone'] = $validator->checkPhone($post['phone']); - $validator = new CaptchaValidator(); + $captcha = $this->getSettings('captcha'); - $validator->checkCode($post['ticket'], $post['rand']); + if ($captcha['enabled'] == 1) { + + $validator = new CaptchaValidator(); + + $validator->checkCode($post['ticket'], $post['rand']); + } $service = new SmsVerifyService();