Files
annotations/Azaion.Common/DTO/User.cs
T
Alex Bezdieniezhnykh 60519461a1 rework to have only 1 exe!
2024-12-04 20:51:26 +02:00

21 lines
567 B
C#

using System.Security.Claims;
namespace Azaion.Common.DTO;
public class User
{
public Guid Id { get; set; }
public string Email { get; set; }
public RoleEnum Role { get; set; }
public User(IEnumerable<Claim> claims)
{
var claimDict = claims.ToDictionary(x => x.Type, x => x.Value);
Id = Guid.Parse(claimDict[Constants.CLAIM_NAME_ID]);
Email = claimDict[Constants.CLAIM_EMAIL];
if (!Enum.TryParse(claimDict[Constants.CLAIM_ROLE], out RoleEnum role))
role = RoleEnum.None;
Role = role;
}
}