You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Dotnet-WebAPI/API/AppHttpContext.cs

16 lines
360 B

using API.Validation;
using Microsoft.AspNetCore.Mvc;
namespace API;
public static class AppHttpContext
{
public static int CurrentUserId(this ControllerBase b)
{
var idClaim = b.HttpContext
.User
.Claims
.First(c => c.Type == IdentityData.IdUserClaimName);
return int.Parse(idClaim.Value);
}
}