ref: project structure

This commit is contained in:
2026-08-19 23:25:08 +07:00
parent 05a93cfc09
commit a1fe31cf70
155 changed files with 3339 additions and 1007 deletions
+19
View File
@@ -0,0 +1,19 @@
using System.Security.Claims;
using Microsoft.IdentityModel.JsonWebTokens;
namespace mws.backend.dotnet.api;
public static class ClaimsExtensions
{
public static Guid GetUserId(this ClaimsPrincipal principal)
{
var value = principal.FindFirstValue(JwtRegisteredClaimNames.Sub)
?? principal.FindFirstValue(ClaimTypes.NameIdentifier)
?? principal.FindFirstValue("sub");
if (value is not null && Guid.TryParse(value, out var id))
{
return id;
}
throw new UnauthorizedAccessException("Invalid user identity");
}
}