This commit is contained in:
Mrx
2026-02-28 15:43:09 +08:00
parent 4825c0562e
commit 60aac5ac94
3 changed files with 138 additions and 2 deletions

View File

@@ -2,11 +2,12 @@ package auth
import (
"context"
"xingfucha-server/common/xerr"
"xingfucha-server/pkg/lzkit/crypto"
"fmt"
"math/rand"
"time"
"xingfucha-server/common/xerr"
"xingfucha-server/pkg/captcha"
"xingfucha-server/pkg/lzkit/crypto"
"github.com/pkg/errors"
@@ -35,6 +36,18 @@ func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLo
}
func (l *SendSmsLogic) SendSms(req *types.SendSmsReq) error {
// 1. 图形验证码校验
cfg := l.svcCtx.Config.Captcha
if err := captcha.Verify(captcha.Config{
AccessKeyID: cfg.AccessKeyID,
AccessKeySecret: cfg.AccessKeySecret,
EndpointURL: cfg.EndpointURL,
SceneID: cfg.SceneID,
}, req.CaptchaVerifyParam); err != nil {
return err
}
// 2. 原有的手机号加密逻辑
secretKey := l.svcCtx.Config.Encrypt.SecretKey
encryptedMobile, err := crypto.EncryptMobile(req.Mobile, secretKey)
if err != nil {