-
Notifications
You must be signed in to change notification settings - Fork 11.4k
fix: allow organizations to sign up with existing usernames #25941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow organizations to sign up with existing usernames #25941
Conversation
- Update usernameCheck to check organization context when currentOrgDomain is provided - Organizations can now use usernames that exist in other orgs or global namespace - Only checks username availability within the specific organization - Fixes issue where org signups were blocked by global username conflicts Refs calcom#25800
|
@Rakshit-gen is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey @Rakshit-gen - code looks good to me - would you be able to upload a before and after demo of the issue youre fixing here. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 1 file
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/lib/server/username.ts">
<violation number="1" location="packages/lib/server/username.ts:134">
P2: When `currentOrgDomain` is provided but the organization is not found, the code silently falls back to checking the global namespace. Consider returning early with an error or explicitly handling this case to avoid unexpected behavior where an invalid org domain causes global namespace checks instead of the intended org-specific check.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
|
hey @sean-brydon i am trying to test it on local but the setup is having some issues, can you please check it on your local |
Sure i can test - can you write me the steps to reproduce the issue you are fixing? |
|
hey @sean-brydon here are the steps for testing Switch to branch: git checkout fix/allow-org-signup-with-existing-usernames |
Oh sweet okay - testing this! |
|
Yes @sean-brydon thanks!! |
|
E2E results are ready! |
Summary
Fixes username validation during organization signup to allow organizations to use usernames that exist in other organizations or the global namespace. Previously, org signups were incorrectly blocked by global username conflicts.
Changes
usernameCheckfunction inpackages/lib/server/username.tsto check organization context whencurrentOrgDomainis providedProblem
Organizations have their own unique usernames (enforced by
@@unique([username, organizationId])in the schema), but the signup validation was checking the global namespace (organizationId: null), preventing org signups from using usernames that existed elsewhere.Solution
When
currentOrgDomainis provided:organizationIdfrom the org slugThis allows organizations to reuse usernames from other orgs or the global namespace, while still preventing duplicates within the same organization.
Testing
checkRegularUsername)Related
Fixes #25800