mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
Removed unnecessary console output in Program.cs and Turnstile.cs to clean up logs and avoid exposing sensitive information. Refactored user.html to replace the `notification` function with `createNotification` for improved notification handling.
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
|
|
namespace Sharpbin
|
|
{
|
|
public class Turnstile
|
|
{
|
|
public static async Task<bool> VerifyTurnstileToken(string token)
|
|
{
|
|
var httpClient = new HttpClient();
|
|
JObject requestBody = new JObject
|
|
{
|
|
["secret"] = Program.cfTurnstileSecret,
|
|
["response"] = token
|
|
};
|
|
var request = new HttpRequestMessage
|
|
{
|
|
Method = HttpMethod.Post,
|
|
RequestUri = new Uri("https://challenges.cloudflare.com/turnstile/v0/siteverify"),
|
|
Content = new StringContent(requestBody.ToString(), Encoding.UTF8, "application/json")
|
|
};
|
|
using (var response = await httpClient.SendAsync(request))
|
|
{
|
|
var jsonresponse = JObject.Parse(await response.Content.ReadAsStringAsync());
|
|
if (jsonresponse["success"]?.ToString().ToLower() == "true")
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|