This commit is contained in:
Mrx
2026-02-28 17:41:30 +08:00
parent fd229f0d59
commit c4cc15f853
3 changed files with 44 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package auth
import (
"context"
"net/http"
"tyass-server/app/main/api/internal/logic/auth"
@@ -23,7 +24,10 @@ func SendSmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
result.ParamValidateErrorResult(r, w, err)
return
}
l := auth.NewSendSmsLogic(r.Context(), svcCtx)
// 将 User-Agent 添加到上下文中
ctx := context.WithValue(r.Context(), "user-agent", r.Header.Get("User-Agent"))
l := auth.NewSendSmsLogic(ctx, svcCtx)
err := l.SendSms(&req)
result.HttpResult(r, w, nil, err)
}

View File

@@ -38,7 +38,7 @@ func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLo
func (l *SendSmsLogic) SendSms(req *types.SendSmsReq) error {
// 图形验证码校验
captchaCfg := l.svcCtx.Config.Captcha
if err := captcha.Verify(captcha.Config{
if err := captcha.VerifyWithContext(l.ctx, captcha.Config{
AccessKeyID: captchaCfg.AccessKeyID,
AccessKeySecret: captchaCfg.AccessKeySecret,
EndpointURL: captchaCfg.EndpointURL,