示例#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
     });
示例#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));
            }
        }
示例#4
0
 public static string GetClaimValue(this ClaimsPrincipal principal, CustomClaimType claimType)
 {
     return(principal.Claims.FirstOrDefault(x => x.Type == GetCustomClaimTypeString(claimType))?.Value);
 }
示例#5
0
 public ClaimModel(string name, CustomClaimType claimTypes, bool check = false)
 {
     Name        = name;
     Checked     = check;
     CustomClaim = claimTypes;
 }
示例#6
0
 public static void AddClaim(this ClaimsIdentity claimIdentity, CustomClaimType customClaimType, string value, string type)
 {
     claimIdentity.AddClaim(new Claim(GetCustomClaimTypeString(customClaimType), value, type));
 }