Skip to content

Commit 0287d04

Browse files
committed
squash
1 parent 87475aa commit 0287d04

3 files changed

Lines changed: 41 additions & 28 deletions

File tree

common/djangoapps/third_party_auth/models.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,25 @@ def get_register_form_data(cls, pipeline_kwargs):
357357

358358
return registration_form_data
359359

360+
def get_registration_field_overrides(self):
361+
"""
362+
Get registration field visibility/requirement overrides for this provider.
363+
364+
This allows providers to configure whether certain fields
365+
(like marketing_emails_opt_in or research) should be required,
366+
optional, or hidden on the registration form.
367+
368+
Returns:
369+
dict: Mapping of field names to settings ("required", "optional", "hidden")
370+
Returns empty dict if no overrides are configured.
371+
372+
Note:
373+
This is a base implementation that returns an empty dict.
374+
Subclasses like SAMLProviderConfig may override this to provide
375+
actual field override configuration.
376+
"""
377+
return {}
378+
360379
def get_authentication_backend(self):
361380
"""Gets associated Django settings.AUTHENTICATION_BACKEND string."""
362381
return f'{self.backend_class.__module__}.{self.backend_class.__name__}'

common/djangoapps/third_party_auth/saml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SAMLAuthBackend(SAMLAuth): # pylint: disable=abstract-method
3333
def get_idp(self, idp_name):
3434
""" Given the name of an IdP, get a SAMLIdentityProvider instance """
3535
from .models import SAMLProviderConfig
36-
return SAMLProviderConfig.current(idp_name).get_config(self)
36+
return SAMLProviderConfig.current(idp_name).get_config()
3737

3838
def setting(self, name, default=None):
3939
""" Get a setting, from SAMLConfiguration """

openedx/core/djangoapps/user_authn/views/registration_form.py

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,33 +1204,27 @@ def _apply_provider_field_overrides(self, form_desc, provider_overrides, field_n
12041204

12051205
override_value = provider_overrides[field_name]
12061206

1207-
if override_value == "hidden":
1208-
# Hide the field completely
1209-
form_desc.override_field_properties(
1210-
field_name,
1211-
field_type="hidden",
1212-
required=False,
1213-
label="",
1214-
instructions="",
1215-
default=""
1216-
)
1217-
return True
1218-
1219-
elif override_value == "required":
1220-
# Make the field required
1221-
form_desc.override_field_properties(
1222-
field_name,
1223-
required=True
1224-
)
1225-
return True
1226-
1227-
elif override_value == "optional":
1228-
# Make the field optional (ensure it's not required)
1229-
form_desc.override_field_properties(
1230-
field_name,
1231-
required=False
1232-
)
1233-
return True
1207+
# Find the field in the form_desc and modify it directly
1208+
for field in form_desc.fields:
1209+
if field['name'] == field_name:
1210+
if override_value == "hidden":
1211+
# Hide the field completely
1212+
field['type'] = 'hidden'
1213+
field['required'] = False
1214+
field['label'] = ''
1215+
field['instructions'] = ''
1216+
field['defaultValue'] = ''
1217+
return True
1218+
1219+
elif override_value == "required":
1220+
# Make the field required
1221+
field['required'] = True
1222+
return True
1223+
1224+
elif override_value == "optional":
1225+
# Make the field optional (ensure it's not required)
1226+
field['required'] = False
1227+
return True
12341228

12351229
return False
12361230

0 commit comments

Comments
 (0)