From 0b76975d41167e137981584a77d9963e54135b40 Mon Sep 17 00:00:00 2001 From: Sadzurami Date: Sat, 31 May 2025 13:56:42 +0300 Subject: [PATCH 1/2] feat: update method IsSessionAlive --- BotLooter/Steam/SteamUserSession.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/BotLooter/Steam/SteamUserSession.cs b/BotLooter/Steam/SteamUserSession.cs index 3c28c85..5f09c11 100644 --- a/BotLooter/Steam/SteamUserSession.cs +++ b/BotLooter/Steam/SteamUserSession.cs @@ -1,4 +1,5 @@ using System.Net; +using System.Text.RegularExpressions; using BotLooter.Resources; using Polly; using Polly.Retry; @@ -54,11 +55,21 @@ private async ValueTask IsSessionAlive() return false; } - var request = new RestRequest("https://store.steampowered.com/account", Method.Head); + var request = new RestRequest("https://steamcommunity.com/my", Method.Get); var response = await WebRequest(request); - return response.ResponseUri is not null && !response.ResponseUri.AbsolutePath.StartsWith("/login"); + if (response.StatusCode == HttpStatusCode.Found) // 302 redirect + { + var location = response.Headers?.FirstOrDefault(h => h.Name?.Equals("Location", StringComparison.OrdinalIgnoreCase) == true)?.Value?.ToString(); + + if (location is not null) + { + return Regex.IsMatch(location, @"steamcommunity\.com(\/(id|profiles)\/[^\/]+)\/?"); + } + } + + return false; } private async Task<(bool Success, string Message)> TryLogin() From ebaa2f34ee419e98a464f97b083c7731b7d2f306 Mon Sep 17 00:00:00 2001 From: Sadzurami Date: Sat, 31 May 2025 14:03:04 +0300 Subject: [PATCH 2/2] fix: add missing headers --- BotLooter/Steam/SteamUserSession.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BotLooter/Steam/SteamUserSession.cs b/BotLooter/Steam/SteamUserSession.cs index 5f09c11..2e192cd 100644 --- a/BotLooter/Steam/SteamUserSession.cs +++ b/BotLooter/Steam/SteamUserSession.cs @@ -57,6 +57,10 @@ private async ValueTask IsSessionAlive() var request = new RestRequest("https://steamcommunity.com/my", Method.Get); + request.AddOrUpdateHeader("Sec-Fetch-Dest", "document"); + request.AddOrUpdateHeader("Sec-Fetch-Mode", "navigate"); + request.AddOrUpdateHeader("Sec-Fetch-Site", "none"); + var response = await WebRequest(request); if (response.StatusCode == HttpStatusCode.Found) // 302 redirect