mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
Workaround for forum returning 203 when KiwiFlare is off for some reason
This commit is contained in:
@@ -84,13 +84,17 @@ public class KfTokenService
|
|||||||
await CheckClearanceToken();
|
await CheckClearanceToken();
|
||||||
using var client = new HttpClient(GetHttpClientHandler());
|
using var client = new HttpClient(GetHttpClientHandler());
|
||||||
var response = await client.GetAsync($"https://{_kfDomain}/login", _ctx);
|
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");
|
_logger.Error("Caught a 203 response when trying to load logon page which means we were KiwiFlare challenged");
|
||||||
throw new KiwiFlareChallengedException();
|
throw new KiwiFlareChallengedException();
|
||||||
}
|
}
|
||||||
response.EnsureSuccessStatusCode();
|
return content;
|
||||||
return await response.Content.ReadAsStreamAsync(_ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> IsLoggedIn()
|
public async Task<bool> IsLoggedIn()
|
||||||
|
|||||||
Reference in New Issue
Block a user