From 1d5cb319a9de9d40a37befb7747e80b078ee4997 Mon Sep 17 00:00:00 2001 From: tone Date: Wed, 17 Dec 2025 23:27:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E8=BF=87=E7=9A=84sms=E4=B8=8D=E4=BC=9A=E4=BD=9C=E4=B8=BA?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=BA=AA=E5=BD=95=E8=A2=AB=E5=8F=96=E5=87=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/backend/src/sms/sms.service.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/backend/src/sms/sms.service.ts b/apps/backend/src/sms/sms.service.ts index 5333979..95111e3 100644 --- a/apps/backend/src/sms/sms.service.ts +++ b/apps/backend/src/sms/sms.service.ts @@ -129,7 +129,6 @@ export class SmsService { phone, type, expiredAt: MoreThan(now), - usedAt: null, }, order: { createdAt: 'DESC' }, }); @@ -141,6 +140,14 @@ export class SmsService { }) } + // 检查被用过没 + if (record.usedAt !== null) { + throw new BusinessException({ + code: ErrorCode.SMS_CODE_EXPIRED, + message: '验证码已失效,请重新获取', + }) + } + // 检查尝试次数 if (record.tryCount >= LoginSmsMaxTryCount) { throw new BusinessException({