From 215b82af6c70d3a8ce7d6ae18988981d90e239e9 Mon Sep 17 00:00:00 2001 From: wkj <278599135@.com> Date: Mon, 25 Dec 2023 16:29:24 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=8F=91=E7=9F=AD=E4=BF=A1=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=A0=81=E6=97=B6=EF=BC=8C=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=8F=AAmock=E7=9F=AD=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/aspects/token.js | 53 +++++++++++++++++++------------------------- lib/aspects/token.js | 50 +++++++++++++++++------------------------ src/aspects/token.ts | 53 +++++++++++++++++--------------------------- 3 files changed, 63 insertions(+), 93 deletions(-) diff --git a/es/aspects/token.js b/es/aspects/token.js index a055626e6..29f279cfc 100644 --- a/es/aspects/token.js +++ b/es/aspects/token.js @@ -1148,37 +1148,30 @@ export async function sendCaptcha({ mobile, env, type: type2, }, context) { }, { dontCollect: true, }); - const result = await sendSms({ - origin: 'tencent', - templateName: '登录', - mobile, - templateParam: { code, duration: duration.toString() }, - }, context); - closeRootMode(); - if (result.success) { - return '验证码已发送'; + + if (process.env.NODE_ENV === 'development' || mockSend) { + closeRootMode(); + return `验证码[${code}]已创建`; + } else { + //发送短信 + const result = await sendSms( + { + origin: 'tencent', + templateName: '登录', + mobile, + templateParam: { + code, + duration: duration.toString(), + }, + }, + context + ); + closeRootMode(); + if (result.success) { + return '验证码已发送'; + } + return '验证码发送失败'; } - return '验证码发送失败'; - // if (process.env.NODE_ENV === 'development' || mockSend) { - // closeRootMode(); - // return `验证码[${code}]已创建`; - // } else { - // //发送短信 - // const result = await sendSms( - // { - // origin: 'tencent', - // templateName: '登录', - // mobile, - // templateParam: { code, duration: duration.toString() }, - // }, - // context - // ); - // closeRootMode(); - // if (result === true) { - // return '验证码已发送'; - // } - // return '验证码发送失败'; - // } } } export async function switchTo({ userId }, context) { diff --git a/lib/aspects/token.js b/lib/aspects/token.js index b4b959980..e27da01de 100644 --- a/lib/aspects/token.js +++ b/lib/aspects/token.js @@ -1157,37 +1157,27 @@ async function sendCaptcha({ mobile, env, type: type2, }, context) { }, { dontCollect: true, }); - const result = await (0, sms_1.sendSms)({ - origin: 'tencent', - templateName: '登录', - mobile, - templateParam: { code, duration: duration.toString() }, - }, context); - closeRootMode(); - if (result.success) { - return '验证码已发送'; + + if (process.env.NODE_ENV === 'development' || mockSend) { + closeRootMode(); + return `验证码[${code}]已创建`; + } else { + //发送短信 + const result = await (0, sms_1.sendSms)( + { + origin: 'tencent', + templateName: '登录', + mobile, + templateParam: { code, duration: duration.toString() }, + }, + context + ); + closeRootMode(); + if (result.success) { + return '验证码已发送'; + } + return '验证码发送失败'; } - return '验证码发送失败'; - // if (process.env.NODE_ENV === 'development' || mockSend) { - // closeRootMode(); - // return `验证码[${code}]已创建`; - // } else { - // //发送短信 - // const result = await sendSms( - // { - // origin: 'tencent', - // templateName: '登录', - // mobile, - // templateParam: { code, duration: duration.toString() }, - // }, - // context - // ); - // closeRootMode(); - // if (result === true) { - // return '验证码已发送'; - // } - // return '验证码发送失败'; - // } } } exports.sendCaptcha = sendCaptcha; diff --git a/src/aspects/token.ts b/src/aspects/token.ts index 041281bad..0df981def 100644 --- a/src/aspects/token.ts +++ b/src/aspects/token.ts @@ -1648,40 +1648,27 @@ export async function sendCaptcha< dontCollect: true, } ); - const result = await sendSms( - { - origin: 'tencent', - templateName: '登录', - mobile, - templateParam: { code, duration: duration.toString() }, - }, - context - ); - closeRootMode(); - if (result.success) { - return '验证码已发送'; + + if (process.env.NODE_ENV === 'development' || mockSend) { + closeRootMode(); + return `验证码[${code}]已创建`; + } else { + //发送短信 + const result = await sendSms( + { + origin: 'tencent', + templateName: '登录', + mobile, + templateParam: { code, duration: duration.toString() }, + }, + context + ); + closeRootMode(); + if (result.success) { + return '验证码已发送'; + } + return '验证码发送失败'; } - return '验证码发送失败'; - // if (process.env.NODE_ENV === 'development' || mockSend) { - // closeRootMode(); - // return `验证码[${code}]已创建`; - // } else { - // //发送短信 - // const result = await sendSms( - // { - // origin: 'tencent', - // templateName: '登录', - // mobile, - // templateParam: { code, duration: duration.toString() }, - // }, - // context - // ); - // closeRootMode(); - // if (result === true) { - // return '验证码已发送'; - // } - // return '验证码发送失败'; - // } } }