From f99b7209bd9733993643ff3e4cddb3f1273fe65d Mon Sep 17 00:00:00 2001 From: andrey-canon Date: Tue, 4 Oct 2022 17:45:15 -0500 Subject: [PATCH] feat: prefill custom fields in the registration form with TPA data. (cherry picked from commit a8ea9dd3625db2ed118acf81c0ea6b6363b2b95b) --- 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 c5cbe633f38..6c1dd7e4207 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -4430,6 +4430,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 e503265d1e6..daa31cadd33 100644 --- a/openedx/core/djangoapps/user_authn/views/registration_form.py +++ b/openedx/core/djangoapps/user_authn/views/registration_form.py @@ -1131,8 +1131,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]