f
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user