Scope invitations by organization when organization scoped
What does this MR do and why?
When within the scope of an organization, we want to limit who can get invited to a project / group to only members from the same organization.
In a nutshell, these things need to happen:
- Only show potential invitees that are scoped to the current organization (by path)
- Show an error if we try to invite someone from another organization (by email or manually passing the user_id)
References
Related #570390
Screenshots or screen recordings
| Before | After |
|---|---|
| Monosnap_screencast_2025-10-30_16-46-47 | Monosnap_screencast_2025-10-30_16-44-24 |
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Example:
-
In rails console enable the feature flag
Feature.enable :organization_switching Feature.enable :ui_for_organizations Feature.enable :organization_scoped_paths -
In the browser, navigate to
http://127.0.0.1:3000and login as an instance admin. -
Click 'New Organization' on the plus drop down in the top left corner:

-
Create a new organization with the name
new-org-1 -
Repeat steps 3-4 and create another organization called
new-org-2 -
Navigate to
http://127.0.0.1:3000/admin/users/newand create a new user with the following properties name:new-user-1username:new-user-1organization:new-org-1email:new-user-1@gitlab.com -
Repeat step 6 and create a user with the following properties: name:
new-user-2username:new-user-2organization:new-org-2email:new-user-2@gitlab.com -
Navigate to
http://127.0.0.1:3000/o/new-org-1/groups/new#create-group-paneand create a new group -
After the group was successfully created, navigate to
Manage -> Members:

-
Click on
Invite Memberson the top right corner:
You should see the invitation modal pop up. -
Type
newand onlynew-user-1should show up. Select that user:

-
You should see the following error:
Remove the faulty email address and try to invite again - it should be successful.
Repeat steps 8-13 again, except with step 8 navigate to http://127.0.0.1:3000/o/new-org-1/projects/new and create a new project instead of a new namespace.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.






