Customizing IdentityUser
IdentityUser has the following fields: Id, Username, Password, Email, and Phonenumber.
Since the display name might differ from the username, we should add a Name property. Say we would like to send birthday wishes to the user; so, we would like to know their date of birth.
To do so, a file called WebAppUser.cs is added to the Data folder that contains the following lines:
using Microsoft.AspNetCore.Identity;
namespace AuthSample.Data;
public class WebAppUser : IdentityUser
{
[PersonalData]
public string? Name { get; set; }
[PersonalData]
public DateTime DOB { get; set; }
}
As shown here, WebAppUser derives from IdentityUser and extends it with the two already-mentioned properties.
In Program.cs, we need to modify the service registration to use the new WebAppUser:
builder.Services.AddDefaultIdentity<WebAppUser>
We also need to change...