From d63f1826fe23d60a7244ec1026884163973fb60c Mon Sep 17 00:00:00 2001 From: Ted Johansson Date: Tue, 25 Jun 2024 19:32:18 +0800 Subject: [PATCH] FEATURE: User fields required for existing users - Part 2 (#27172) We want to allow admins to make new required fields apply to existing users. In order for this to work we need to have a way to make those users fill up the fields on their next page load. This is very similar to how adding a 2FA requirement post-fact works. Users will be redirected to a page where they can fill up the remaining required fields, and until they do that they won't be able to do anything else. --- .../components/admin-user-field-item.hbs | 29 +- .../addon/components/admin-user-field-item.js | 35 +- .../user-menu/profile-tab-content.hbs | 2 +- .../discourse/app/components/user-nav.hbs | 2 +- .../app/controllers/preferences/profile.js | 23 ++ .../app/routes/preferences-profile.js | 19 + .../discourse/app/routes/preferences.js | 4 +- .../app/templates/preferences/profile.hbs | 335 +++++++++--------- .../tests/acceptance/user-menu-test.js | 2 +- app/controllers/application_controller.rb | 29 ++ app/controllers/email_controller.rb | 5 +- app/controllers/extra_locales_controller.rb | 1 + .../finish_installation_controller.rb | 5 +- app/controllers/highlight_js_controller.rb | 1 + app/controllers/invites_controller.rb | 1 + app/controllers/metadata_controller.rb | 5 +- app/controllers/offline_controller.rb | 5 +- app/controllers/pageview_controller.rb | 1 + app/controllers/presence_controller.rb | 2 +- app/controllers/published_pages_controller.rb | 2 +- app/controllers/qunit_controller.rb | 7 +- app/controllers/robots_txt_controller.rb | 5 +- app/controllers/session_controller.rb | 1 + app/controllers/site_controller.rb | 4 +- app/controllers/static_controller.rb | 2 +- app/controllers/stylesheets_controller.rb | 1 + app/controllers/svg_sprite_controller.rb | 1 + .../theme_javascripts_controller.rb | 1 + app/controllers/uploads_controller.rb | 1 + app/controllers/user_api_keys_controller.rb | 4 +- app/controllers/user_avatars_controller.rb | 1 + .../users/omniauth_callbacks_controller.rb | 2 +- app/controllers/users_controller.rb | 2 + app/controllers/users_email_controller.rb | 1 + app/models/user.rb | 16 + app/models/user_field.rb | 10 + app/models/user_history.rb | 2 + app/models/user_required_fields_version.rb | 14 + app/serializers/current_user_serializer.rb | 1 + app/services/user_updater.rb | 7 + config/locales/client.en.yml | 9 +- config/locales/server.en.yml | 2 +- ...226_create_user_required_fields_version.rb | 11 + .../chat/incoming_webhooks_controller.rb | 4 +- spec/models/user_spec.rb | 41 +++ spec/requests/application_controller_spec.rb | 39 ++ spec/services/user_updater_spec.rb | 69 ++-- spec/system/admin_user_fields_spec.rb | 34 ++ .../page_objects/pages/admin_user_fields.rb | 6 + .../pages/user_preferences_profile.rb | 12 + .../user_preferences_profile_spec.rb | 52 +++ 51 files changed, 661 insertions(+), 209 deletions(-) create mode 100644 app/models/user_required_fields_version.rb create mode 100644 db/migrate/20240531053226_create_user_required_fields_version.rb create mode 100644 spec/system/page_objects/pages/user_preferences_profile.rb create mode 100644 spec/system/user_page/user_preferences_profile_spec.rb diff --git a/app/assets/javascripts/admin/addon/components/admin-user-field-item.hbs b/app/assets/javascripts/admin/addon/components/admin-user-field-item.hbs index a6bdfc2183e..82e174efe77 100644 --- a/app/assets/javascripts/admin/addon/components/admin-user-field-item.hbs +++ b/app/assets/javascripts/admin/addon/components/admin-user-field-item.hbs @@ -34,17 +34,36 @@ + +