fix(user_authn): expose country field by default so Profile MFE can list countries#38313
fix(user_authn): expose country field by default so Profile MFE can list countries#38313kingoftech-v01 wants to merge 1 commit intoopenedx:masterfrom
Conversation
…ist countries The default for REGISTRATION_EXTRA_FIELDS['country'] was 'hidden', which caused the registration form API to exclude the country field and its options list. The Profile MFE depends on this API to render its country dropdown, so the dropdown showed no options after the Ulmo upgrade. Change the default to 'optional'. Operators who do not want the country field on the registration form can still override it to 'hidden' via site configuration or YAML env config. Closes openedx#38195
|
Thanks for the pull request, @kingoftech-v01! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Submit a signed contributor agreement (CLA)
If you've signed an agreement in the past, you may need to re-sign. Once you've signed the CLA, please allow 1 business day for it to be processed. 🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Description
After the Ulmo upgrade, the country dropdown in the Profile MFE shows no options. This fix changes the default value of
REGISTRATION_EXTRA_FIELDS['country']from'hidden'to'optional'so the country list is exposed via the registration form API that the Profile MFE relies on.User impact (Learner): Learners can once again select their country in the Profile MFE. The country field also becomes an optional field on the registration form by default.
User impact (Operator): Operators who do not want the country field visible on the registration form can override it via site configuration or YAML env config (e.g.
REGISTRATION_EXTRA_FIELDS: {country: hidden}or{country: required}).Root Cause
openedx/envs/common.py:1689—REGISTRATION_EXTRA_FIELDS['country']defaulted to'hidden'.openedx/core/djangoapps/user_authn/views/registration_form.py:341—_is_field_visible()returnsFalsefor'hidden'.openedx/core/djangoapps/user_authn/views/registration_form.py:517—get_registration_form()skips fields where_is_field_visible()isFalse.openedx/core/djangoapps/user_authn/views/register.py:556—RegistrationView.get()returns the form description via/api/user/v2/account/registration/.'hidden'as the default, thecountryfield and itsoptionslist were never in the response.Previously, Tutor injected
country: requiredin the generated config; that override was removed or changed in Ulmo, exposing the insecure-by-default.Fix
One-line change in
openedx/envs/common.py:A comment explains the rationale and notes that operators can still override it.
Why not fix the Profile MFE instead?
Decoupling the Profile MFE from the registration form API would require changes in a different repo and a new backend endpoint, and leaves the current API contract broken for any other consumer that needs the country list. Changing the default here:
optionalas a sensible platform default (users can choose to provide it or not)Supporting Information
@override_settings, so the default change does not affect them.Testing Instructions
REGISTRATION_EXTRA_FIELDSoverrideREGISTRATION_EXTRA_FIELDS: {country: hidden}in site configuration — the country field should disappear from both the registration form and the Profile MFEFour new tests are included in
openedx/core/djangoapps/user_authn/views/tests/test_register.py:test_unit_country_default_is_optional— Unittest_integration_country_field_exposed_by_default— Integrationtest_bug_38195_regression_profile_mfe_gets_country_options— Regressiontest_operator_can_still_hide_country— Backwards-compat for operator overrideDeadline
None
Other Information
Closes #38195