JudahGabriel / RavenDB.Identity

RavenDB Identity provider for ASP.NET Core. Let RavenDB manage your users and logins.
https://www.nuget.org/packages/RavenDB.Identity/1.0.0
MIT License
61 stars 29 forks source link

Option to setup a custom username that is different from the email and is still unique for each user #51

Open luis-fss opened 8 months ago

luis-fss commented 8 months ago

Do you think it is feasible to add an option to configure a custom username that is different from the email and still unique for each user?

I ask because the user can change their email, but in my use case the username could not be changed and it must be something more concise and shorter than an email.

Thanks.

luis-fss commented 8 months ago

If it's of interest, I have made a fork with this feature (and some other changes), at first I didn't intend to create a pull request and the code isn't prepared for that (in fact it's a mess, sorry), but I think it demonstrates my idea in this specific feature.

https://github.com/luis-fss/RavenDB.Identity

JudahGabriel commented 7 months ago

Do you think it is feasible to add an option to configure a custom username that is different from the email and still unique for each user?

Sure. How do you envision this changing the behavior of Raven.Identity - ID generation being different?

luis-fss commented 7 months ago

I don't think any changes are necessary in the ID generation, the UserIdType.UserName option already exists.

What I thought is:

  1. An option to set the UserName different from the user's email, in this case changing the email would not change the UserName along with it;
  2. Enforce UserName-based uniqueness, just like email with the compare/exchange mechanism;
  3. Finally, perhaps add an option to prevent the UserName from being changed, but maybe this responsibility should be left to app/dev.

Personally, I understand that this can generate too much complexity in the code base, especially in the Create(User)Asyn and Update(User)Asyn methods to ensure that the UserName is unique, but I also think it is a valid feature and use case .

luis-fss commented 7 months ago

That being said... Of course it's your decision, but don't feel compelled in any way. This project is already quite useful as it is. Thank you.