This commit is contained in:
Mrx
2026-02-26 17:45:58 +08:00
parent e1fbf72437
commit f4deb0063b
15 changed files with 296 additions and 17 deletions

View File

@@ -7,6 +7,7 @@ import (
"os"
"time"
"tydata-server/common/xerr"
"tydata-server/pkg/captcha"
"tydata-server/pkg/lzkit/crypto"
"github.com/pkg/errors"
@@ -53,6 +54,23 @@ func (l *SendSmsLogic) SendSms(req *types.SendSmsReq) error {
return errors.Wrapf(xerr.NewErrMsg("一分钟内不能重复发送验证码"), "短信发送, 手机号1分钟内重复请求发送验证码: %s", encryptedMobile)
}
// 验证码校验
if os.Getenv("ENV") != "development" {
if req.CaptchaVerifyParam == "" {
return errors.Wrapf(xerr.NewErrMsg("图形验证码校验失败"), "短信发送, 验证码参数为空: %s", encryptedMobile)
}
captchaCfg := l.svcCtx.Config.Captcha
err = captcha.Verify(captcha.Config{
AccessKeyID: captchaCfg.AccessKeyID,
AccessKeySecret: captchaCfg.AccessKeySecret,
EndpointURL: captchaCfg.EndpointURL,
SceneID: captchaCfg.SceneID,
}, req.CaptchaVerifyParam)
if err != nil {
return errors.Wrapf(xerr.NewErrMsg("图形验证码校验失败"), "短信发送, 验证码校验失败: %s", encryptedMobile)
}
}
// 开发环境固定验证码为138888
env := os.Getenv("ENV")
var code string