This commit is contained in:
Mrx
2026-05-11 15:02:57 +08:00
parent 9c4fd95955
commit 467f081a1a
27 changed files with 14 additions and 8 deletions

View File

@@ -113,7 +113,8 @@ var productHandlers = map[string]queryHandlerFunc{
// productHasSmsCode 表示该 product 解密后的请求结构体中是否包含必填短信验证码 Code。
// 有 Code 的产品在「获取验证码」时已经做了滑块,这里不再强制要求 CaptchaVerifyParam。
// 其他产品(无 Code在查询时必须传并校验 CaptchaVerifyParam防止跳过图形验证
// 其他产品(无 Code在查询时必须传并校验 CaptchaVerifyParam防止跳过图形验证
// 微信小程序X-Platform: wxmini见 ctxdata.GetPlatformFromCtx不嵌入 H5 滑块,由 PreprocessLogic 跳过图形校验。
func productHasSmsCode(product string) bool {
switch product {
case "marriage",
@@ -140,8 +141,14 @@ func productHasSmsCode(product string) bool {
}
func (l *QueryServiceLogic) PreprocessLogic(req *types.QueryServiceReq, product string) (*types.QueryServiceResp, error) {
// 无短信验证码 Code 的 product查询前必须传并校验滑块,否则不允许跳过
if !productHasSmsCode(product) {
// 无短信验证码 Code 的 product查询前必须传并校验滑块;微信小程序端跳过(依赖登录态与 X-Platform
requireCaptcha := !productHasSmsCode(product)
if requireCaptcha {
if plat, platErr := ctxdata.GetPlatformFromCtx(l.ctx); platErr == nil && plat == model.PlatformWxMini {
requireCaptcha = false
}
}
if requireCaptcha {
if req.CaptchaVerifyParam == "" {
return nil, errors.Wrapf(xerr.NewErrMsg("请完成图形验证"), "product %s requires captcha", product)
}