Practice battles work

This commit is contained in:
gamer147
2026-05-23 22:46:11 -04:00
parent 704542786a
commit 21b97269ff
15 changed files with 34968 additions and 82 deletions

View File

@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SVSim.EmulatedEntrypoint.Constants;
using SVSim.EmulatedEntrypoint.Security;
using SVSim.EmulatedEntrypoint.Security.SteamSessionAuthentication;
@@ -14,5 +15,16 @@ namespace SVSim.EmulatedEntrypoint.Controllers
[Authorize(AuthenticationSchemes = SteamAuthenticationConstants.SchemeName)]
public abstract class SVSimController : ControllerBase
{
/// <summary>
/// Reads the authenticated viewer's internal id from the ViewerId claim populated by
/// <c>SteamSessionAuthenticationHandler</c>. Returns false (and viewerId = 0) when the
/// claim is missing or unparseable — handler should respond with Unauthorized().
/// </summary>
protected bool TryGetViewerId(out long viewerId)
{
viewerId = 0;
var claim = User.Claims.FirstOrDefault(c => c.Type == ShadowverseClaimTypes.ViewerIdClaim)?.Value;
return claim is not null && long.TryParse(claim, out viewerId);
}
}
}