Newsbot.Collector/Newsbot.Collector.Api/Middleware/JwtUserIdExtension.cs

14 lines
322 B
C#
Raw Normal View History

namespace Newsbot.Collector.Api.Authentication;
public static class JwtUserIdExtension
{
public static string GetUserId(this HttpContext context)
{
if (context.User == null)
{
return string.Empty;
}
return context.User.Claims.Single(x => x.Type == "id").Value;
}
}