(actionConfig *CaptchaAction, req requests.Request, writer http.ResponseWriter, originURL string)
| 852 | } |
| 853 | |
| 854 | func (this *CaptchaValidator) showGeeTestForm(actionConfig *CaptchaAction, req requests.Request, writer http.ResponseWriter, originURL string) { |
| 855 | var geeTestConfig = actionConfig.GeeTestConfig |
| 856 | if geeTestConfig == nil || !geeTestConfig.IsOn { |
| 857 | return |
| 858 | } |
| 859 | |
| 860 | var lang = actionConfig.Lang |
| 861 | if len(lang) == 0 { |
| 862 | var acceptLanguage = req.WAFRaw().Header.Get("Accept-Language") |
| 863 | if len(acceptLanguage) > 0 { |
| 864 | langIndex := strings.Index(acceptLanguage, ",") |
| 865 | if langIndex > 0 { |
| 866 | lang = acceptLanguage[:langIndex] |
| 867 | } |
| 868 | } |
| 869 | } |
| 870 | if len(lang) == 0 { |
| 871 | lang = "en-US" |
| 872 | } |
| 873 | |
| 874 | var msgTitle string |
| 875 | |
| 876 | switch lang { |
| 877 | case "zh-CN": |
| 878 | msgTitle = "身份验证" |
| 879 | case "zh-TW": |
| 880 | msgTitle = "身份驗證" |
| 881 | default: |
| 882 | msgTitle = "Verify Yourself" |
| 883 | } |
| 884 | |
| 885 | var msgHTML = `<!DOCTYPE html> |
| 886 | <html> |
| 887 | <head> |
| 888 | <title>` + msgTitle + `</title> |
| 889 | <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"> |
| 890 | <meta charset="UTF-8"/> |
| 891 | <script type="text/javascript" src="//static.geetest.com/v4/gt4.js"></script> |
| 892 | <script type="text/javascript">` + axiosJavascript + `</script> |
| 893 | </head> |
| 894 | <body> |
| 895 | <script> |
| 896 | var originURL = ` + strconv.Quote(originURL) + `; |
| 897 | initGeetest4({ |
| 898 | captchaId: ` + strconv.Quote(geeTestConfig.CaptchaId) + `, |
| 899 | product: "bind", |
| 900 | }, function (gt) { |
| 901 | gt.onSuccess(function () { |
| 902 | var result = gt.getValidate(); |
| 903 | axios.post("` + req.WAFRaw().URL.String() + "&" + captchaIdName + `=none", result, { |
| 904 | "Content-Type": "application/json" |
| 905 | }).then(function (resp) { |
| 906 | if (resp.status == 200) { |
| 907 | window.location = originURL; |
| 908 | } |
| 909 | }); |
| 910 | }) |
| 911 | gt.showCaptcha(); |
no test coverage detected