diff --git a/lms/djangoapps/student_account/views.py b/lms/djangoapps/student_account/views.py index 06aafdfa2e2b..c1d74e20a41f 100644 --- a/lms/djangoapps/student_account/views.py +++ b/lms/djangoapps/student_account/views.py @@ -107,12 +107,25 @@ def login_and_registration_form(request, initial_mode="login"): if ext_auth_response is not None: return ext_auth_response + third_party_auth = _third_party_auth_context(request, redirect_to) + if not third_party_auth['currentProvider']: + if settings.APPSEMBLER_FEATURES.get('ENABLE_EXCLUSIVE_SSO_LOGISTRATION'): + urls_dict = configuration_helpers.get_value( + 'EXCLUSIVE_SSO_LOGISTRATION_URL_MAP', + settings.EXCLUSIVE_SSO_LOGISTRATION_URL_MAP) + + if initial_mode == 'register': + if 'register' in urls_dict: + return redirect(urls_dict['register']) + else: + return redirect(urls_dict['login']) + # Otherwise, render the combined login/registration page context = { 'data': { 'login_redirect_url': redirect_to, 'initial_mode': initial_mode, - 'third_party_auth': _third_party_auth_context(request, redirect_to), + 'third_party_auth': third_party_auth, 'third_party_auth_hint': third_party_auth_hint or '', 'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME), 'support_link': configuration_helpers.get_value('SUPPORT_SITE_LINK', settings.SUPPORT_SITE_LINK), diff --git a/lms/envs/aws_appsembler.py b/lms/envs/aws_appsembler.py index 8a82cf2ef401..a6b807b7537e 100644 --- a/lms/envs/aws_appsembler.py +++ b/lms/envs/aws_appsembler.py @@ -122,6 +122,8 @@ #default behavior is to replace the existing backends with those in APPSEMBLER_FEATURES AUTHENTICATION_BACKENDS = tuple(APPSEMBLER_FEATURES['LMS_AUTHENTICATION_BACKENDS']) +EXCLUSIVE_SSO_LOGISTRATION_URL_MAP = ENV_TOKENS.get('EXCLUSIVE_SSO_LOGISTRATION_URL_MAP', {}) + #attempt to import model from our custom fork of edx-organizations # if it works, then also add the middleware try: diff --git a/lms/envs/devstack_appsembler.py b/lms/envs/devstack_appsembler.py index 7ba9aa2d3fec..81084f30aff3 100644 --- a/lms/envs/devstack_appsembler.py +++ b/lms/envs/devstack_appsembler.py @@ -111,6 +111,8 @@ #default behavior is to replace the existing backends with those in APPSEMBLER_FEATURES AUTHENTICATION_BACKENDS = tuple(APPSEMBLER_FEATURES['LMS_AUTHENTICATION_BACKENDS']) +EXCLUSIVE_SSO_LOGISTRATION_URL_MAP = ENV_TOKENS.get('EXCLUSIVE_SSO_LOGISTRATION_URL_MAP', {}) + #attempt to import model from our custom fork of edx-organizations # if it works, then also add the middleware try: