//2025-11-01 Google dropping support for captcha, just nuking it for now, see how much spam I get
This commit is contained in:
@@ -51,14 +51,15 @@ namespace contact.Pages
|
||||
}
|
||||
|
||||
|
||||
if (!ReCaptchaPassed(
|
||||
Request.Form["g-recaptcha-response"], // that's how you get it from the Request object
|
||||
_configuration.GetSection("GoogleReCaptcha:secret").Value
|
||||
))
|
||||
{
|
||||
//Return a fail code that will hopefully take us off the spammers list
|
||||
return StatusCode(500);
|
||||
}
|
||||
//2025-11-01 Google dropping support for captcha, just nuking it for now, see how much spam I get
|
||||
// if (!ReCaptchaPassed(
|
||||
// Request.Form["g-recaptcha-response"], // that's how you get it from the Request object
|
||||
// _configuration.GetSection("GoogleReCaptcha:secret").Value
|
||||
// ))
|
||||
// {
|
||||
// //Return a fail code that will hopefully take us off the spammers list
|
||||
// return StatusCode(500);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@@ -166,26 +167,26 @@ namespace contact.Pages
|
||||
}
|
||||
|
||||
|
||||
//2025-11-01 Google dropping support for captcha, just nuking it for now, see how much spam I get
|
||||
// public static bool ReCaptchaPassed(string gRecaptchaResponse, string secret)
|
||||
// {
|
||||
// HttpClient httpClient = new HttpClient();
|
||||
// var res = httpClient.GetAsync($"https://www.google.com/recaptcha/api/siteverify?secret={secret}&response={gRecaptchaResponse}").Result;
|
||||
// if (res.StatusCode != HttpStatusCode.OK)
|
||||
// {
|
||||
// // logger.LogError("Error while sending request to ReCaptcha");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public static bool ReCaptchaPassed(string gRecaptchaResponse, string secret)
|
||||
{
|
||||
HttpClient httpClient = new HttpClient();
|
||||
var res = httpClient.GetAsync($"https://www.google.com/recaptcha/api/siteverify?secret={secret}&response={gRecaptchaResponse}").Result;
|
||||
if (res.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
// logger.LogError("Error while sending request to ReCaptcha");
|
||||
return false;
|
||||
}
|
||||
// string JSONres = res.Content.ReadAsStringAsync().Result;
|
||||
// dynamic JSONdata = JObject.Parse(JSONres);
|
||||
// if (JSONdata.success != "true")
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
string JSONres = res.Content.ReadAsStringAsync().Result;
|
||||
dynamic JSONdata = JObject.Parse(JSONres);
|
||||
if (JSONdata.success != "true")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user