From 702e31e5436e1b0e754f46c02700d29bf393727f Mon Sep 17 00:00:00 2001 From: wkj <278599135@.com> Date: Tue, 1 Jul 2025 11:49:22 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E9=82=AE=E4=BB=B6=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81=E8=BF=87=E6=BB=A4=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/aspects/token.js | 12 ++++++++++++ lib/aspects/token.js | 12 ++++++++++++ src/aspects/token.ts | 19 ++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/es/aspects/token.js b/es/aspects/token.js index 4f27c353d..4dbd00063 100644 --- a/es/aspects/token.js +++ b/es/aspects/token.js @@ -1003,6 +1003,16 @@ export async function bindByMobile(params, context) { throw new OakUserException('验证码已经过期'); } // 到这里说明验证码已经通过 + await context.operate('captcha', { + id: await generateNewIdAsync(), + action: 'update', + data: { + expired: true + }, + filter: { + id: captchaRow.id + } + }, {}); // 检查当前user是否已绑定mobile const [boundMobile] = await context.select('mobile', { data: { @@ -1945,6 +1955,7 @@ export async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, c const [count1, count2] = await Promise.all([ context.count('captcha', { filter: { + origin: 'mobile', visitorId, $$createAt$$: { $gt: now - 3600 * 1000, @@ -2093,6 +2104,7 @@ export async function sendCaptchaByEmail({ email, env, type: captchaType, }, con const [count1, count2] = await Promise.all([ context.count('captcha', { filter: { + origin: 'email', visitorId, $$createAt$$: { $gt: now - 3600 * 1000, diff --git a/lib/aspects/token.js b/lib/aspects/token.js index ee11cbff2..4ff16bfe6 100644 --- a/lib/aspects/token.js +++ b/lib/aspects/token.js @@ -1011,6 +1011,16 @@ async function bindByMobile(params, context) { throw new types_1.OakUserException('验证码已经过期'); } // 到这里说明验证码已经通过 + await context.operate('captcha', { + id: await (0, uuid_1.generateNewIdAsync)(), + action: 'update', + data: { + expired: true + }, + filter: { + id: captchaRow.id + } + }, {}); // 检查当前user是否已绑定mobile const [boundMobile] = await context.select('mobile', { data: { @@ -1961,6 +1971,7 @@ async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, context) const [count1, count2] = await Promise.all([ context.count('captcha', { filter: { + origin: 'mobile', visitorId, $$createAt$$: { $gt: now - 3600 * 1000, @@ -2110,6 +2121,7 @@ async function sendCaptchaByEmail({ email, env, type: captchaType, }, context) { const [count1, count2] = await Promise.all([ context.count('captcha', { filter: { + origin: 'email', visitorId, $$createAt$$: { $gt: now - 3600 * 1000, diff --git a/src/aspects/token.ts b/src/aspects/token.ts index a2d9cb5e4..4b0894265 100644 --- a/src/aspects/token.ts +++ b/src/aspects/token.ts @@ -1291,8 +1291,22 @@ export async function bindByMobile( if (captchaRow.expired) { throw new OakUserException('验证码已经过期'); } - // 到这里说明验证码已经通过 + await context.operate( + 'captcha', + { + id: await generateNewIdAsync(), + action: 'update', + data: { + expired: true + }, + filter: { + id: captchaRow.id! + } + }, + {} + ); + // 检查当前user是否已绑定mobile const [boundMobile] = await context.select( 'mobile', @@ -1311,6 +1325,7 @@ export async function bindByMobile( forUpdate: true, } ) + if (boundMobile) { //用户已绑定的mobile与当前输入的mobile一致 if (boundMobile.mobile === mobile) { @@ -2619,6 +2634,7 @@ export async function sendCaptchaByMobile( 'captcha', { filter: { + origin: 'mobile', visitorId, $$createAt$$: { $gt: now - 3600 * 1000, @@ -2804,6 +2820,7 @@ export async function sendCaptchaByEmail( 'captcha', { filter: { + origin: 'email', visitorId, $$createAt$$: { $gt: now - 3600 * 1000,