Skip to content

Fix #4632: Reject usernames used by other users - #4643

Merged
mathjazz merged 1 commit into
mozilla:mainfrom
rohitmulani63-ops:fix-4632-username-clash
Nov 4, 2026
Merged

mathjazz merged 1 commit into
mozilla:mainfrom
rohitmulani63-ops:fix-4632-username-clash

Conversation

@rohitmulani63-ops

Copy link
Copy Markdown
Contributor

fixes #4632

since #4630, get_user_by_username prefers a custom profile username over a generated User.username, so a custom username equal to another user's generated one would take over their /contributors/{username}/ page and the /api/v2/users/{username}/translations/ lookup.

this adds a clean_username to UserProfileForm that rejects a custom username if it matches any other user's User.username, ignoring case. the user's own generated username is still allowed, and an empty username is accepted like before.

tests in pontoon/contributors/tests/test_views.py, the three cases asked for on the issue:

  • another user's username in a different case: 400 with "This username is already taken."
  • the user's own generated username: accepted
  • empty username: accepted

the production audit and any cleanup aren't included, since you mentioned handling those separately.

tested on my fork's CI (Backend and Python linting workflows, on this commit plus a fork-only change to their push triggers): https://github.com/rohitmulani63-ops/pontoon/actions/runs/41914912613 (1098 passed), https://github.com/rohitmulani63-ops/pontoon/actions/runs/41914912554 (ruff check and ruff format --check)

Since mozilla#4630, a custom profile username takes precedence over a
generated User.username when resolving profile URLs. Reject a custom
username that matches another user's User.username, ignoring case.
The user's own generated username and an empty username are still
accepted.

@mathjazz mathjazz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the patch and welcome to Pontoon!

@mathjazz
mathjazz merged commit 3158848 into mozilla:main Nov 4, 2026
7 checks passed
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.

Prevent custom usernames that match another user's generated username

2 participants