Skip to content

Add a setting that allows for creation of new users with private profile

Manoj M J requested to merge 231301-user-private-profile-enabled-by-default into master

What does this MR do and why?

For #231301 (closed).

This MR:

  • adds a migration to add a new column to ApplicationSetting table named user_defaults_to_private_profile, which is the instance setting.
  • Makes this instance setting is controllable via the Admin UI and the application setting API.
  • Whenever a new user is created via the UI (via admin or a new signup) or the API, the value of this instance setting is respected, and is set as the value of user.private_profile
  • However, admins will have the ability to override this setting when creating a new user via the UI or API. In such cases, the instance setting is not respected, and the override is respected.
  • Admins can also now modify existing users via the UI or the API to set the value of user.private_profile to either true or false. When modifying an existing user's value of the private_profile attribute, the instance setting is not respected.

Migrations

UP Migration
rake db:migrate
main: == 20221219135535 AddUserDefaultsToPrivateProfileToApplicationSettings: migrating
main: -- add_column(:application_settings, :user_defaults_to_private_profile, :boolean, {:default=>false, :null=>false})
main:    -> 0.0049s
main: == 20221219135535 AddUserDefaultsToPrivateProfileToApplicationSettings: migrated (0.0104s)

ci: == 20221219135535 AddUserDefaultsToPrivateProfileToApplicationSettings: migrating
ci: -- add_column(:application_settings, :user_defaults_to_private_profile, :boolean, {:default=>false, :null=>false})
ci:    -> 0.0047s
ci: == 20221219135535 AddUserDefaultsToPrivateProfileToApplicationSettings: migrated (0.0088s)
DOWN migration
rake db:migrate:down:main VERSION=20221219135535
main: == 20221219135535 AddUserDefaultsToPrivateProfileToApplicationSettings: reverting
main: -- remove_column(:application_settings, :user_defaults_to_private_profile, :boolean, {:default=>false, :null=>false})
main:    -> 0.0031s
main: == 20221219135535 AddUserDefaultsToPrivateProfileToApplicationSettings: reverted (0.0066s)
rake db:migrate:down:ci VERSION=20221219135535
ci: == 20221219135535 AddUserDefaultsToPrivateProfileToApplicationSettings: reverting
ci: -- remove_column(:application_settings, :user_defaults_to_private_profile, :boolean, {:default=>false, :null=>false})
ci:    -> 0.0032s
ci: == 20221219135535 AddUserDefaultsToPrivateProfileToApplicationSettings: reverted (0.0098s)

Screenshots or screen recordings

I have uploaded a walkthrough video on Unfiltered with all the details: https://youtu.be/X7afG0MBrOc (private, GitLab only)

Screenshots:

Screenshot_2023-01-04_at_2.59.29_PM

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #231301 (closed)

Edited by Manoj M J

Merge request reports