up add sms

This commit is contained in:
Mrx
2026-02-25 16:38:58 +08:00
parent ed5ebc5648
commit 60a0770917
14 changed files with 321 additions and 23 deletions

View File

@@ -2,11 +2,12 @@ package auth
import (
"context"
"ycc-server/common/xerr"
"ycc-server/pkg/lzkit/crypto"
"fmt"
"math/rand"
"time"
"ycc-server/common/xerr"
"ycc-server/pkg/captcha"
"ycc-server/pkg/lzkit/crypto"
"github.com/pkg/errors"
@@ -35,6 +36,20 @@ func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLo
}
func (l *SendSmsLogic) SendSms(req *types.SendSmsReq) error {
// 1. 阿里云滑块验证码校验(防盗刷)
cfg := l.svcCtx.Config.Captcha
if cfg.SceneID != "" {
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 {