Add user setting for "Home organization"
Related to #419079 (closed)
We need a setting to allow a user to set their "Home organization". A user can potentially be a user in one or many Organizations. This "Home organization" will be used in the following cases:
- When a user logs into GitLab they need to land within one of those Organizations.
- If viewing a User Profile when outside an Organization (ie when logged out) to provide information about the user, the user must be presented in the context of an Organization.
The frontend for this setting will be completed in #419079 (closed)
Implementation guide
- Database migration to add the new column with default value on
user_preferences
- Make sure that the controller that's referenced in the thread
☝ can update/get the new column value - Update the
initial_selection
key inOrganizations::OrganizationHelper#home_organization_setting_app_data
to return the ID of the selected home organization.
Questions and answers
- What table should this setting be saved in?
user_preferences
- What should we name the table column?
- Needs answer. Maybe
home_organization_id
?
- Needs answer. Maybe
- Should we verify the user belongs to that organization before saving?
- Needs answer
- Should this setting default to the "Default organization" (https://gitlab.com/-/organizations/default)?
- Yes. But if the sign up flow later includes an organization that a user can join, then this can change. But at least in the database, the new column can default to the Default organization id
- What happens to this setting if a user is removed from their "Home organization"?
- "Home organization" setting falls back to default organization
Edited by Peter Hegman