Skip to content

Commit 42e22c1

Browse files
committed
temp: allow making email read-only for selected SSO providers
1 parent 87ef2af commit 42e22c1

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

openedx/core/djangoapps/user_api/accounts/settings_views.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ def account_settings(request):
8383
context, account_settings_template = AccountSettingsRenderStarted.run_filter(
8484
context=context, template_name=account_settings_template,
8585
)
86+
87+
# If the user has a connected third party auth provider that is in the list of providers specified in
88+
# `THIRD_PARTY_AUTH_READ_ONLY_EMAIL_PROVIDERS``, we want to make the email field read-only.
89+
# We could have used the filter for this, but given that Ulmo no longer has the legacy Account Settings page,
90+
# this is only temporary code.
91+
target_providers = getattr(settings, 'THIRD_PARTY_AUTH_READ_ONLY_EMAIL_PROVIDERS', [])
92+
providers = context.get('auth', {}).get('providers', [])
93+
any_connected = any(p.get('id') in target_providers and p.get('connected', False) for p in providers)
94+
if any_connected:
95+
context['sync_learner_profile_data'] = True
96+
context['enterprise_readonly_account_fields']['fields'].append('email')
97+
8698
except AccountSettingsRenderStarted.RenderInvalidAccountSettings as exc:
8799
response = render_to_response(exc.account_settings_template, exc.template_context)
88100
except AccountSettingsRenderStarted.RedirectToPage as exc:

0 commit comments

Comments
 (0)