From 28fd41d51102b8d860bf4946711c1f5aef479b41 Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Tue, 22 Jul 2025 22:57:23 -0500 Subject: [PATCH] Workaround for forum returning 203 when KiwiFlare is off for some reason --- KfChatDotNetBot/Services/KfTokenService.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/KfChatDotNetBot/Services/KfTokenService.cs b/KfChatDotNetBot/Services/KfTokenService.cs index 0070bde..bfd94b2 100644 --- a/KfChatDotNetBot/Services/KfTokenService.cs +++ b/KfChatDotNetBot/Services/KfTokenService.cs @@ -84,13 +84,17 @@ public class KfTokenService await CheckClearanceToken(); using var client = new HttpClient(GetHttpClientHandler()); var response = await client.GetAsync($"https://{_kfDomain}/login", _ctx); - if (response.StatusCode == HttpStatusCode.NonAuthoritativeInformation) + response.EnsureSuccessStatusCode(); + var content = await response.Content.ReadAsStreamAsync(_ctx); + var document = new HtmlDocument(); + document.Load(content); + var challengeData = document.DocumentNode.SelectSingleNode("//html[@id=\"sssg\"]"); + if (response.StatusCode == HttpStatusCode.NonAuthoritativeInformation && challengeData != null) { _logger.Error("Caught a 203 response when trying to load logon page which means we were KiwiFlare challenged"); throw new KiwiFlareChallengedException(); } - response.EnsureSuccessStatusCode(); - return await response.Content.ReadAsStreamAsync(_ctx); + return content; } public async Task IsLoggedIn()