邮件、短信发送验证码错误时,增加error打印
This commit is contained in:
parent
d9b3277596
commit
6932752ecd
|
|
@ -1961,31 +1961,6 @@ export async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, c
|
|||
};
|
||||
let code = captcha?.code;
|
||||
if (captcha) {
|
||||
// const code = captcha.code!;
|
||||
// if (mockSend) {
|
||||
// closeRootMode();
|
||||
// return `验证码[${code}]已创建`;
|
||||
// } else if (now - (captcha.$$createAt$$! as number) < 60000) {
|
||||
// closeRootMode();
|
||||
// throw new OakUserException('您的操作太迅捷啦,请稍候再点吧');
|
||||
// } else {
|
||||
// assert(origin, '必须设置短信渠道');
|
||||
// // todo 再次发送
|
||||
// const result = await sendSms<ED>(
|
||||
// {
|
||||
// origin: origin,
|
||||
// templateName: codeTemplateName,
|
||||
// mobile,
|
||||
// templateParam: { code, duration: duration.toString() },
|
||||
// },
|
||||
// context
|
||||
// );
|
||||
// closeRootMode();
|
||||
// if (result.success) {
|
||||
// return '验证码已发送';
|
||||
// }
|
||||
// return '验证码发送失败';
|
||||
// }
|
||||
const captchaDuration = process.env.NODE_ENV === 'development' ? 10 * 1000 : 60 * 1000;
|
||||
if (now - captcha.$$createAt$$ < captchaDuration) {
|
||||
closeRootMode();
|
||||
|
|
@ -2012,6 +1987,7 @@ export async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, c
|
|||
if (result.success) {
|
||||
return '验证码已发送';
|
||||
}
|
||||
console.error('短信发送失败,原因:\n', result?.res);
|
||||
return '验证码发送失败';
|
||||
}
|
||||
}
|
||||
|
|
@ -2140,27 +2116,6 @@ export async function sendCaptchaByEmail({ email, env, type: captchaType, }, con
|
|||
};
|
||||
let code = captcha?.code;
|
||||
if (captcha) {
|
||||
// const code = captcha.code!;
|
||||
// if (mockSend) {
|
||||
// closeRootMode();
|
||||
// return `验证码[${code}]已创建`;
|
||||
// } else if (now - (captcha.$$createAt$$! as number) < 60000) {
|
||||
// closeRootMode();
|
||||
// throw new OakUserException('您的操作太迅捷啦,请稍候再点吧');
|
||||
// } else {
|
||||
// assert(config.account, '必须设置邮箱');
|
||||
// // todo 再次发送
|
||||
// const text = config.text?.replace('${duration}', duration.toString()).replace('${code}', code);
|
||||
// const html = config.html?.replace('${duration}', duration.toString()).replace('${code}', code);
|
||||
// emailOptions.text = text;
|
||||
// emailOptions.html = html;
|
||||
// const result = await sendEmail(emailOptions, context);
|
||||
// closeRootMode();
|
||||
// if (result.success) {
|
||||
// return '验证码已发送';
|
||||
// }
|
||||
// return '验证码发送失败';
|
||||
// }
|
||||
const captchaDuration = process.env.NODE_ENV === 'development' ? 10 * 1000 : 60 * 1000;
|
||||
if (now - captcha.$$createAt$$ < captchaDuration) {
|
||||
closeRootMode();
|
||||
|
|
@ -2188,6 +2143,7 @@ export async function sendCaptchaByEmail({ email, env, type: captchaType, }, con
|
|||
if (result.success) {
|
||||
return '验证码已发送';
|
||||
}
|
||||
console.error('邮件发送失败,原因:\n', result?.error);
|
||||
return '验证码发送失败';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1977,31 +1977,6 @@ async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, context)
|
|||
};
|
||||
let code = captcha?.code;
|
||||
if (captcha) {
|
||||
// const code = captcha.code!;
|
||||
// if (mockSend) {
|
||||
// closeRootMode();
|
||||
// return `验证码[${code}]已创建`;
|
||||
// } else if (now - (captcha.$$createAt$$! as number) < 60000) {
|
||||
// closeRootMode();
|
||||
// throw new OakUserException('您的操作太迅捷啦,请稍候再点吧');
|
||||
// } else {
|
||||
// assert(origin, '必须设置短信渠道');
|
||||
// // todo 再次发送
|
||||
// const result = await sendSms<ED>(
|
||||
// {
|
||||
// origin: origin,
|
||||
// templateName: codeTemplateName,
|
||||
// mobile,
|
||||
// templateParam: { code, duration: duration.toString() },
|
||||
// },
|
||||
// context
|
||||
// );
|
||||
// closeRootMode();
|
||||
// if (result.success) {
|
||||
// return '验证码已发送';
|
||||
// }
|
||||
// return '验证码发送失败';
|
||||
// }
|
||||
const captchaDuration = process.env.NODE_ENV === 'development' ? 10 * 1000 : 60 * 1000;
|
||||
if (now - captcha.$$createAt$$ < captchaDuration) {
|
||||
closeRootMode();
|
||||
|
|
@ -2028,6 +2003,7 @@ async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, context)
|
|||
if (result.success) {
|
||||
return '验证码已发送';
|
||||
}
|
||||
console.error('短信发送失败,原因:\n', result?.res);
|
||||
return '验证码发送失败';
|
||||
}
|
||||
}
|
||||
|
|
@ -2157,27 +2133,6 @@ async function sendCaptchaByEmail({ email, env, type: captchaType, }, context) {
|
|||
};
|
||||
let code = captcha?.code;
|
||||
if (captcha) {
|
||||
// const code = captcha.code!;
|
||||
// if (mockSend) {
|
||||
// closeRootMode();
|
||||
// return `验证码[${code}]已创建`;
|
||||
// } else if (now - (captcha.$$createAt$$! as number) < 60000) {
|
||||
// closeRootMode();
|
||||
// throw new OakUserException('您的操作太迅捷啦,请稍候再点吧');
|
||||
// } else {
|
||||
// assert(config.account, '必须设置邮箱');
|
||||
// // todo 再次发送
|
||||
// const text = config.text?.replace('${duration}', duration.toString()).replace('${code}', code);
|
||||
// const html = config.html?.replace('${duration}', duration.toString()).replace('${code}', code);
|
||||
// emailOptions.text = text;
|
||||
// emailOptions.html = html;
|
||||
// const result = await sendEmail(emailOptions, context);
|
||||
// closeRootMode();
|
||||
// if (result.success) {
|
||||
// return '验证码已发送';
|
||||
// }
|
||||
// return '验证码发送失败';
|
||||
// }
|
||||
const captchaDuration = process.env.NODE_ENV === 'development' ? 10 * 1000 : 60 * 1000;
|
||||
if (now - captcha.$$createAt$$ < captchaDuration) {
|
||||
closeRootMode();
|
||||
|
|
@ -2205,6 +2160,7 @@ async function sendCaptchaByEmail({ email, env, type: captchaType, }, context) {
|
|||
if (result.success) {
|
||||
return '验证码已发送';
|
||||
}
|
||||
console.error('邮件发送失败,原因:\n', result?.error);
|
||||
return '验证码发送失败';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2632,31 +2632,6 @@ export async function sendCaptchaByMobile<ED extends EntityDict>(
|
|||
}
|
||||
let code = captcha?.code!;
|
||||
if (captcha) {
|
||||
// const code = captcha.code!;
|
||||
// if (mockSend) {
|
||||
// closeRootMode();
|
||||
// return `验证码[${code}]已创建`;
|
||||
// } else if (now - (captcha.$$createAt$$! as number) < 60000) {
|
||||
// closeRootMode();
|
||||
// throw new OakUserException('您的操作太迅捷啦,请稍候再点吧');
|
||||
// } else {
|
||||
// assert(origin, '必须设置短信渠道');
|
||||
// // todo 再次发送
|
||||
// const result = await sendSms<ED>(
|
||||
// {
|
||||
// origin: origin,
|
||||
// templateName: codeTemplateName,
|
||||
// mobile,
|
||||
// templateParam: { code, duration: duration.toString() },
|
||||
// },
|
||||
// context
|
||||
// );
|
||||
// closeRootMode();
|
||||
// if (result.success) {
|
||||
// return '验证码已发送';
|
||||
// }
|
||||
// return '验证码发送失败';
|
||||
// }
|
||||
const captchaDuration = process.env.NODE_ENV === 'development' ? 10 * 1000 : 60 * 1000;
|
||||
if (now - (captcha.$$createAt$$! as number) < captchaDuration) {
|
||||
closeRootMode();
|
||||
|
|
@ -2684,6 +2659,7 @@ export async function sendCaptchaByMobile<ED extends EntityDict>(
|
|||
if (result.success) {
|
||||
return '验证码已发送';
|
||||
}
|
||||
console.error('短信发送失败,原因:\n', result?.res);
|
||||
return '验证码发送失败';
|
||||
}
|
||||
}
|
||||
|
|
@ -2848,27 +2824,6 @@ export async function sendCaptchaByEmail<ED extends EntityDict>(
|
|||
|
||||
let code = captcha?.code!;
|
||||
if (captcha) {
|
||||
// const code = captcha.code!;
|
||||
// if (mockSend) {
|
||||
// closeRootMode();
|
||||
// return `验证码[${code}]已创建`;
|
||||
// } else if (now - (captcha.$$createAt$$! as number) < 60000) {
|
||||
// closeRootMode();
|
||||
// throw new OakUserException('您的操作太迅捷啦,请稍候再点吧');
|
||||
// } else {
|
||||
// assert(config.account, '必须设置邮箱');
|
||||
// // todo 再次发送
|
||||
// const text = config.text?.replace('${duration}', duration.toString()).replace('${code}', code);
|
||||
// const html = config.html?.replace('${duration}', duration.toString()).replace('${code}', code);
|
||||
// emailOptions.text = text;
|
||||
// emailOptions.html = html;
|
||||
// const result = await sendEmail(emailOptions, context);
|
||||
// closeRootMode();
|
||||
// if (result.success) {
|
||||
// return '验证码已发送';
|
||||
// }
|
||||
// return '验证码发送失败';
|
||||
// }
|
||||
const captchaDuration = process.env.NODE_ENV === 'development' ? 10 * 1000 : 60 * 1000;
|
||||
if (now - (captcha.$$createAt$$! as number) < captchaDuration) {
|
||||
closeRootMode();
|
||||
|
|
@ -2894,6 +2849,7 @@ export async function sendCaptchaByEmail<ED extends EntityDict>(
|
|||
if (result.success) {
|
||||
return '验证码已发送';
|
||||
}
|
||||
console.error('邮件发送失败,原因:\n', result?.error);
|
||||
return '验证码发送失败';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue