Practice battles work
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user