Validate login request and refactor login handling

This commit is contained in:
Holden
2026-06-19 14:58:02 -05:00
parent 63730dbba0
commit 076fed09f2
10 changed files with 32 additions and 7 deletions

View File

@@ -16,8 +16,18 @@ public class SteamAuthValidator(ISteamAuthService steamAuthService) : IPlatformA
string platformId,
CancellationToken ct = default)
{
var steamParams = JsonSerializer.Deserialize<SteamPlatformAuth>(platformAuthentication);
if (steamParams == null)
SteamPlatformAuth? steamParams;
try
{
steamParams = JsonSerializer.Deserialize<SteamPlatformAuth>(platformAuthentication);
}
catch (JsonException)
{
return PlatformAuthResult.Failure("Invalid authentication");
}
if (steamParams?.AppId is null || string.IsNullOrWhiteSpace(steamParams.Ticket))
return PlatformAuthResult.Failure("Invalid authentication");
var result = await steamAuthService.AuthorizeAsync(steamParams.Ticket, steamParams.AppId.AppId, ct);