public static string GetCustomClaimTypeString(CustomClaimType customClaimType) { return(customClaimType switch { CustomClaimType.U_Id => ClaimTypes.NameIdentifier, CustomClaimType.Email => "Email", CustomClaimType.UserName => "UserName", CustomClaimType.NextCheckTime => "NextCheckTime", _ => null });
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)); } }
public static string GetClaimValue(this ClaimsPrincipal principal, CustomClaimType claimType) { return(principal.Claims.FirstOrDefault(x => x.Type == GetCustomClaimTypeString(claimType))?.Value); }
public ClaimModel(string name, CustomClaimType claimTypes, bool check = false) { Name = name; Checked = check; CustomClaim = claimTypes; }
public static void AddClaim(this ClaimsIdentity claimIdentity, CustomClaimType customClaimType, string value, string type) { claimIdentity.AddClaim(new Claim(GetCustomClaimTypeString(customClaimType), value, type)); }