Application is Blazor Server .NET Core 5.0
I am using .NET Core's Identity system and I am running into a problem. I want to have the person's first name stored with the Identity so I can call on it easily.
Currently I have a class overriding the base identity:
public class ApplicationUser : IdentityUser
{
public ApplicationUser() : base() { }
[StringLength(100)]
public string FirstName { get; set; }
[StringLength(100)]
public string LastName { get; set; }
}
My startup.cs has:
services.AddDefaultIdentity<ApplicationUser>(options => {
options.SignIn.RequireConfirmedAccount = true;
}
)
In my mind that should force the program's intellisense to understand ApplicationUser is the default class when looking for identity.
However, when I try to call:
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
It only returns "IdentityUser" data rather than my custom ApplicationUser class.
Is there something I am missing with what AuthenticationStateProvider is returning or a type casting I am missing?
Also, if this is completely incorrect, should I do this with Claims? If so, I cannot find a concrete way to effectively use claims with Blazor Server.