Skip to content

feat: prevent usernames colliding with known routes - #199

Open
robsimmons wants to merge 1 commit into
vitest-introfrom
rename-usernames-at-creation
Open

robsimmons wants to merge 1 commit into
vitest-introfrom
rename-usernames-at-creation

Conversation

@robsimmons

@robsimmons robsimmons commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

This PR does two things:

  • Adds isAvailableUsername, which allows us to reject already-existing or disallowed usernames. (This doesn't handle race conditions so we're still relying somewhat on the database-level constraint to avoid collision with existing usernames.)
  • Adds a retry mechanism findSuitableAlphaNumName that tries to find an acceptable name given a function that rejects unacceptable names. When there's a collision, removes any existing numeric postfix and tries to add postfixes starting with 1.

Closes #132.

@robsimmons
robsimmons changed the base branch from main to betterauth-1-7 October 28, 2026 20:47
Comment thread .gitignore

# testing
/coverage
coverage/

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed to prevent /shared/coverage from being .gitnotignored as well

@robsimmons
robsimmons added this pull request to stack #201 October 28, 2026 20:50
@robsimmons robsimmons changed the title feat: rename conflicting usernames feat: prevent usernames colliding with known routes Oct 28, 2026
@robsimmons
robsimmons force-pushed the rename-usernames-at-creation branch from 1d6c3f9 to 0eafc3a Compare October 28, 2026 23:21
Base automatically changed from betterauth-1-7 to main October 28, 2026 23:22
@robsimmons
robsimmons force-pushed the rename-usernames-at-creation branch 3 times, most recently from 3952bf3 to b45f4e4 Compare October 29, 2026 21:07
@robsimmons
robsimmons removed this pull request from stack #201 October 30, 2026 12:18
@robsimmons
robsimmons force-pushed the rename-usernames-at-creation branch 2 times, most recently from 5633d29 to 18a6193 Compare October 30, 2026 12:23
@robsimmons
robsimmons changed the base branch from main to vitest-intro October 30, 2026 12:24
@robsimmons
robsimmons force-pushed the rename-usernames-at-creation branch from 18a6193 to 25ed6f4 Compare October 30, 2026 12:24
@robsimmons
robsimmons requested a review from Vtec234 October 30, 2026 12:25
@robsimmons
robsimmons force-pushed the rename-usernames-at-creation branch from 25ed6f4 to 7f75b20 Compare October 30, 2026 12:31
@robsimmons
robsimmons added this pull request to stack #206 October 30, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deal with name collisions

1 participant