GetCurrentUserId
Reads the caller's public identifier from a ClaimsPrincipal, checking the userId claim first and falling back to ClaimTypes.NameIdentifier.
If neither claim is present, or the value is not a well-formed identifier, it throws MissingUserIdClaimException rather than returning a default, which reaches the client as 401. Use TryGetCurrentUserId where an anonymous caller is expected.
Usage
csharp
using System.Security.Claims;
using AlmightyShogun.AspNet.Auth;
Guid identifier = principal.GetCurrentUserId();Returns
The caller's public identifier.Type signature
csharp
public Guid GetCurrentUserId();