From c67a46362eaf67cc054acdda4a61b0388c6eb962 Mon Sep 17 00:00:00 2001 From: TL Date: Thu, 7 Jul 2022 17:32:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=BE=E5=AE=A2=E6=89=BE=E5=9B=9E=E5=AF=86?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beike/Repositories/VerifyCodeRepo.php | 5 +++++ beike/Shop/Services/AccountService.php | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/beike/Repositories/VerifyCodeRepo.php b/beike/Repositories/VerifyCodeRepo.php index a6124526..fe8b97bc 100644 --- a/beike/Repositories/VerifyCodeRepo.php +++ b/beike/Repositories/VerifyCodeRepo.php @@ -41,6 +41,11 @@ class VerifyCodeRepo return VerifyCode::query()->where('account', $account)->first(); } + public static function deleteByAccount($account) + { + return VerifyCode::query()->where('account', $account)->delete(); + } + /** * @param $id * @return void diff --git a/beike/Shop/Services/AccountService.php b/beike/Shop/Services/AccountService.php index 2d2caa4d..d1b8061e 100644 --- a/beike/Shop/Services/AccountService.php +++ b/beike/Shop/Services/AccountService.php @@ -52,6 +52,7 @@ class AccountService public static function sendVerifyCodeForForgotten($email, $type) { $code = str_pad(mt_rand(10, 999999), 6, '0', STR_PAD_LEFT); + VerifyCodeRepo::deleteByAccount($email); VerifyCodeRepo::create([ 'account' => $email, 'code' => $code, @@ -90,6 +91,6 @@ class AccountService throw new \Exception("找回密码类型错误"); } CustomerRepo::update($customer, ['password' => $password]); - + $verifyCode->delete(); } }