From e32579ab6e02223258c5598f59a0364f4f13cd5d Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Mon, 8 May 2023 23:38:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=AA=8C=E8=AF=81=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E7=A9=BA=E5=8F=A3=E4=BB=A4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Verify.php | 4 ++++ app/Validators/Verify.php | 32 ++++++++------------------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/app/Services/Verify.php b/app/Services/Verify.php index 36fc9fcc..d304cfb6 100644 --- a/app/Services/Verify.php +++ b/app/Services/Verify.php @@ -51,6 +51,8 @@ class Verify extends Service $value = $this->cache->get($key); + if (empty($value)) return false; + return $code == $value; } @@ -60,6 +62,8 @@ class Verify extends Service $value = $this->cache->get($key); + if (empty($value)) return false; + return $code == $value; } diff --git a/app/Validators/Verify.php b/app/Validators/Verify.php index 3e991c4b..e4d2ab3d 100644 --- a/app/Validators/Verify.php +++ b/app/Validators/Verify.php @@ -45,6 +45,10 @@ class Verify extends Validator public function checkSmsCode($phone, $code) { + if (empty($code)) { + throw new BadRequestException('verify.invalid_sms_code'); + } + $service = new VerifyService(); $result = $service->checkSmsCode($phone, $code); @@ -56,6 +60,10 @@ class Verify extends Validator public function checkMailCode($email, $code) { + if (empty($code)) { + throw new BadRequestException('verify.invalid_mail_code'); + } + $service = new VerifyService(); $result = $service->checkMailCode($email, $code); @@ -65,28 +73,4 @@ class Verify extends Validator } } - public function checkRand($rand) - { - list($time, $number) = explode('-', $rand); - - if (abs($time - time()) > 300) { - throw new BadRequestException('verify.invalid_rand'); - } - - if ($number < 1000 || $number > 9999) { - throw new BadRequestException('verify.invalid_rand'); - } - - return $rand; - } - - public function checkTicket($ticket, $rand) - { - $ticket = $this->crypt->decrypt($ticket); - - if ($ticket != $rand) { - throw new BadRequestException('verify.invalid_ticket'); - } - } - }