NormalizedUserName VS Username in DotNet Core

pedrommuller picture pedrommuller · Sep 23, 2016 · Viewed 12.8k times · Source

I'm trying to create a custom implementation of IUserLoginStore for MongoDB and I noticed when using

UserManager<ApplicationUser>

with the method

 var userResult = await _userManager.CreateAsync(user);

it goes through the implementation of

GetUserNameAsync
FindByNameAsync
SetNormalizedUserNameAsync
GetUserIdAsync

I would like to clarify two questions:

  • what's the purpose of having a NormalizedUsername and a UserName? the only difference that I could notice id that the normalizedUserName is in uppercase.

  • I'm using my Implementation only to store users from an external login(Google plus), is there a way that I can omit username and NormilizedUserName since basically, I'm using the email in these three fields, I'm feeling that I'm duplicating data and it doesn't make any sense to me.

any recommendations?

Answer

blowdart picture blowdart · Sep 23, 2016

1) Normalization stops people registering user names which only differ in letter casing.

2) No - those fields are part of the basic data model.