using System; using System.Security.Claims; using IOL.Fagprove.Data.Enums; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using IOL.Fagprove.Utilities; namespace IOL.Fagprove.Controllers { [Authorize] [Produces(("application/json"))] [ApiController] [Route("api/[controller]")] public class BaseController : ControllerBase { public LoggedInUserModel LoggedInUser => new LoggedInUserModel { Id = User.GetClaimValue(ClaimTypes.NameIdentifier).ToGuid(), Name = User.GetClaimValue(ClaimTypes.Name), Role = User.GetClaimValue(ClaimTypes.Role).ToUserRole() }; public class LoggedInUserModel { public Guid Id { get; set; } public string Name { get; set; } public UserRole Role { get; set; } } } }