Loading
Allow admins to change enterprise user primary email via Users API
What does this MR do and why?
Allows admins to change an enterprise user's primary email via the Users API, aligning with what is already possible in the Admin area UI (source).
References
Screenshots or screen recordings
| Before | After |
|---|---|
|
How to set up and validate locally
- Simulate SaaS
- Create a test user with an
example.comemail - Create a top-level group
- Create a project within the group
- Verify the domain within the top-level group
-
group = Group.find(GROUP_ID) project = group.projects.first project.pages_domains.create!(domain: 'example.com', verified_at: Time.current)
-
- If set up correctly, the user will be claimed as an Enterprise user. For testing purposes in the local environment, you can claim the user manually from the Rails console:
-
user = User.find_by_username('USERNAME') user.user_detail.update(enterprise_group_id: group, enterprise_group_associated_at: Time.current)
-
- Add a secondary email to the user
-
Emails::CreateService.new(User.first, { user: user, email: "249641_repro@test.test", skip_confirmation: true }).execute
-
- Using an admin PAT, use the Users API to update the primary email:
-
curl --location --request PUT 'https://gdk.test:3443/api/v4/users/ID' \ --header 'PRIVATE-TOKEN: TOKEN' \ --header 'Content-Type: application/json' \ --data-raw '{ "email": "249641_repro@test.test" }'
-
- Observe that the primary email has changed, releasing them from the Enterprise group
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.
Edited by Jio Castillo