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 '验证码发送失败'; - // } } }