RavenDB.Identity icon indicating copy to clipboard operation
RavenDB.Identity copied to clipboard

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

Open luis-fss opened this issue 1 year ago • 4 comments

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 avatar Jan 13 '24 01:01 luis-fss

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

luis-fss avatar Jan 13 '24 02:01 luis-fss

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?

JudahGabriel avatar Jan 18 '24 21:01 JudahGabriel

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 avatar Jan 19 '24 01:01 luis-fss

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.

luis-fss avatar Jan 19 '24 01:01 luis-fss