Exemplo n.º 1
0
 public static string GetCustomClaimTypeString(CustomClaimType customClaimType)
 {
     return(customClaimType switch
     {
         CustomClaimType.U_Id => ClaimTypes.NameIdentifier,
         CustomClaimType.Email => "Email",
         CustomClaimType.UserName => "UserName",
         CustomClaimType.NextCheckTime => "NextCheckTime",
         _ => null
     });
Exemplo n.º 2
0
        public static string GetCustomClaimTypeString(CustomClaimType customClaimType)
        {
            switch (customClaimType)
            {
            case CustomClaimType.UserId: return(ClaimTypes.NameIdentifier);

            case CustomClaimType.NextCheckDate: return("NextCheckDate");

            default: return(null);
            }
        }
        public void OnGet()
        {
            Array EnumValues = Enum.GetValues(typeof(CustomClaimType));

            Model.CustomClaims = new List <ClaimModel>();
            foreach (object item in EnumValues)
            {
                CustomClaimType CurrentEnum = (CustomClaimType)Enum.Parse(typeof(CustomClaimType), item.ToString());
                Model.CustomClaims.Add(new ClaimModel(CurrentEnum.ToDisplay(), CurrentEnum));
            }
        }
Exemplo n.º 4
0
 public static string GetClaimValue(this ClaimsPrincipal principal, CustomClaimType claimType)
 {
     return(principal.Claims.FirstOrDefault(x => x.Type == GetCustomClaimTypeString(claimType))?.Value);
 }
Exemplo n.º 5
0
 public ClaimModel(string name, CustomClaimType claimTypes, bool check = false)
 {
     Name        = name;
     Checked     = check;
     CustomClaim = claimTypes;
 }
Exemplo n.º 6
0
 public static void AddClaim(this ClaimsIdentity claimIdentity, CustomClaimType customClaimType, string value, string type)
 {
     claimIdentity.AddClaim(new Claim(GetCustomClaimTypeString(customClaimType), value, type));
 }