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?
NormalizedUsername - Which contains the uppercase value of the Username. NormalizedEmail - Which contains the uppercase value of the Email.
ASP.NET Core Identity: Is an API that supports user interface (UI) login functionality. Manages users, passwords, profile data, roles, claims, tokens, email confirmation, and more.
ASP.NET Core Identity provides a framework for managing and storing user accounts in ASP.NET Core apps. Identity is added to your project when Individual User Accounts is selected as the authentication mechanism. By default, Identity makes use of an Entity Framework (EF) Core data model.
1) Normalization stops people registering user names which only differ in letter casing.
2) No - those fields are part of the basic data model.
FindByNameAsync
should search by u.Name case-insensitive (do you trust your DB settings?)GetNormalizedUserNameAsync
should return user.Name.ToUpperCase()SetNormalizedUserNameAsync
should do nothingPlease note that 2.1 can skip any index on name
column in DB and hurt performance of your app (check your DB, again). Or cause 'client-side' execution (and again, dramatically hurt performance). Depending of your implementation.
I use such "minimized" User
class only in internal enterprise systems which uses only specific OAuth provider and accepting users only from specified domain (Google Apps). This systems does not perform any search by user name and I safely throw NotImplementedException
in many methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With