I am working with the IdentityUser class [Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUser], and would like to extend (or override) the IdentityUser class to allow null(able) claim values, but am having a hard time trying to figure out how to override the class and create the logic to allow this. Please let me know if anyone can assist.
Thank you.
This is the code I have started, but not sure how to get it implemented correctly, and or what additional logic needs to be changed/added to make it work.
public class CustomUser : IdentityUser
{
private ICollection<CustomClaim<string>> _claims { get; set; }
public CustomUser()
{
_claims = new List<CustomClaim<string>>();
}
public override ICollection<IdentityUserClaim<string>> Claims
{
get => _claims;
}
public class CustomClaim<TKey> : IdentityUserClaim<string>
{
public override string ClaimValue
{
get {
if (base.ClaimValue != null)
{
return base.ClaimValue;
}
else
{
return "null";
}
}
set => base.ClaimValue = value;
}
}
}