NormalizedUserName VS Username in DotNet Core

家住魔仙堡 提交于 2019-12-04 22:47:45

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

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

  1. Yes, you can (if you really want):
    1. FindByNameAsync should search by u.Name case-insensitive (do you trust your DB settings?)
    2. GetNormalizedUserNameAsync should return user.Name.ToUpperCase()
    3. SetNormalizedUserNameAsync should do nothing

Please 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!