mirror of
https://github.com/azaion/annotations.git
synced 2026-04-23 02:26:31 +00:00
21 lines
599 B
C#
21 lines
599 B
C#
using System.Security.Claims;
|
|
|
|
namespace Azaion.CommonSecurity.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[SecurityConstants.CLAIM_NAME_ID]);
|
|
Email = claimDict[SecurityConstants.CLAIM_EMAIL];
|
|
if (!Enum.TryParse(claimDict[SecurityConstants.CLAIM_ROLE], out RoleEnum role))
|
|
role = RoleEnum.None;
|
|
Role = role;
|
|
}
|
|
} |