Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions BotLooter/Steam/SteamUserSession.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net;
using System.Text.RegularExpressions;
using BotLooter.Resources;
using Polly;
using Polly.Retry;
Expand Down Expand Up @@ -54,11 +55,25 @@ private async ValueTask<bool> IsSessionAlive()
return false;
}

var request = new RestRequest("https://store.steampowered.com/account", Method.Head);
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);

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()
Expand Down