From 43e57401fe18c328d18874bdd1bdb1f9f589283e Mon Sep 17 00:00:00 2001 From: andrey-canon Date: Tue, 19 Nov 2024 17:10:09 -0500 Subject: [PATCH] feat: prefill custom fields in the registration form with TPA data (cherry picked from commit f99b7209bd9733993643ff3e4cddb3f1273fe65d) --- lms/envs/common.py | 6 ++++++ .../core/djangoapps/user_authn/views/registration_form.py | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index 5f8714ca9cf7..fab8daaf081a 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -4534,6 +4534,12 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring REGISTRATION_EXTENSION_FORM = None +# .. setting_name: REGISTRATION_EXTENSION_FORM_FIELDS_TPA_OVERRIDES +# .. setting_default: [] +# .. setting_description: List of custom fields included in the registriation +# form extension to be prefilled with third party auth data. +REGISTRATION_EXTENSION_FORM_FIELDS_TPA_OVERRIDES = [] + # Identifier included in the User Agent from open edX mobile apps. MOBILE_APP_USER_AGENT_REGEXES = [ r'edX/org.edx.mobile', diff --git a/openedx/core/djangoapps/user_authn/views/registration_form.py b/openedx/core/djangoapps/user_authn/views/registration_form.py index 1d1089ce0214..eb0c7ce9c3f0 100644 --- a/openedx/core/djangoapps/user_authn/views/registration_form.py +++ b/openedx/core/djangoapps/user_authn/views/registration_form.py @@ -1134,8 +1134,13 @@ def _apply_third_party_auth_overrides(self, request, form_desc): current_provider.skip_registration_form and enterprise_customer_for_request(request) ) or current_provider.sync_learner_profile_data ) + registration_fields = ( + self.DEFAULT_FIELDS + + self.EXTRA_FIELDS + + settings.REGISTRATION_EXTENSION_FORM_FIELDS_TPA_OVERRIDES + ) - for field_name in self.DEFAULT_FIELDS + self.EXTRA_FIELDS: + for field_name in registration_fields: if field_name in field_overrides: form_desc.override_field_properties( field_name, default=field_overrides[field_name]