fix: auth providers generate unique username on conflict#23853
Merged
Adzouz merged 6 commits intostrapi:developfrom Apr 17, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Closed
2 tasks
|
@ndinevski is attempting to deploy a commit to the Strapi Team on Vercel. A member of the Team first needs to authorize it. |
0decaac to
a3c2109
Compare
Contributor
|
Hey @innerdvations, I added some tests and the code looks good to me, all subjects were addressed. Do you think we can move forward and merge? (I'll run the piplelines) |
…t from email Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
…h padded and unique
a3c2109 to
1048259
Compare
Contributor
|
I haven't had a chance to review this again, but as long as the previous comment about using the same default values as before is addressed, that was my only blocker :) |
Adzouz
approved these changes
Apr 17, 2026
Contributor
Adzouz
left a comment
There was a problem hiding this comment.
Let's merge it 🚀 Thanks a lot @ndinevski and sorry for the delay 🙏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does it do?
This change appends a number at the end of a username if the username generated from the PROVIDER email is already taken instead of making a duplicate username.
Why is it needed?
fix #23852
This change is motivated by a bug I incountered in my application. Registering normally, with a username
joe, after which trying to register withjoe@gmail.comor any other provider, due to the current handling of usernames, allowed the user to be created with the usernamejoeagain. Leaving us with 2 users with the same username. This is a breaking issue, that needs to be looked at. I think it is best to append a counter at the end of an already taken username in these scenarios. Initially registerjoewould still stay. Newly registered with provider,joe@gmail.comwill get the usernamejoe1instead of the duplicatejoe, which fixes the issue.How to test it?
Register using a username that you have a username on any provider with, ex.
joeand you have an email ex.joe@random.com. It is important not to use the google account here and use a different email. After this user any auth provider login/register, and register with the provider account ex.joe@google.com. A user with usernamejoe1will be created, instead of the duplicatejoe. Therefore fixing the issue.