ENT-2894: Use new welcome template when redirected from enterprise proxy login view (#24587)
* using new welcome template when redirected from enterprise proxy login view * enabling safe redirects to enterprise learner portal from login in devstack * ading admin portal to login redirect whitelist * running make upgrade to version bump edx-enterprise
This commit is contained in:
@@ -232,7 +232,6 @@ def login_and_registration_form(request, initial_mode="login"):
|
||||
settings.FEATURES['ENABLE_COMBINED_LOGIN_REGISTRATION_FOOTER']
|
||||
),
|
||||
}
|
||||
|
||||
enterprise_customer = enterprise_customer_for_request(request)
|
||||
update_logistration_context_for_enterprise(request, context, enterprise_customer)
|
||||
|
||||
|
||||
@@ -424,15 +424,17 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
|
||||
|
||||
@mock.patch('openedx.core.djangoapps.user_authn.views.login_form.enterprise_customer_for_request')
|
||||
@ddt.data(
|
||||
('signin_user', False, None, None),
|
||||
('register_user', False, None, None),
|
||||
('signin_user', True, 'Fake EC', 'http://logo.com/logo.jpg'),
|
||||
('register_user', True, 'Fake EC', 'http://logo.com/logo.jpg'),
|
||||
('signin_user', True, 'Fake EC', None),
|
||||
('register_user', True, 'Fake EC', None),
|
||||
('signin_user', False, None, None, False),
|
||||
('register_user', False, None, None, False),
|
||||
('signin_user', True, 'Fake EC', 'http://logo.com/logo.jpg', False),
|
||||
('register_user', True, 'Fake EC', 'http://logo.com/logo.jpg', False),
|
||||
('signin_user', True, 'Fake EC', 'http://logo.com/logo.jpg', True),
|
||||
('register_user', True, 'Fake EC', 'http://logo.com/logo.jpg', True),
|
||||
('signin_user', True, 'Fake EC', None, False),
|
||||
('register_user', True, 'Fake EC', None, False),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_enterprise_register(self, url_name, ec_present, ec_name, logo_url, mock_get_ec):
|
||||
def test_enterprise_register(self, url_name, ec_present, ec_name, logo_url, is_proxy, mock_get_ec):
|
||||
"""
|
||||
Verify that when an EnterpriseCustomer is received on the login and register views,
|
||||
the appropriate sidebar is rendered.
|
||||
@@ -445,7 +447,11 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
|
||||
else:
|
||||
mock_get_ec.return_value = None
|
||||
|
||||
response = self.client.get(reverse(url_name), HTTP_ACCEPT="text/html")
|
||||
params = []
|
||||
if is_proxy:
|
||||
params.append(("proxy_login", "True"))
|
||||
|
||||
response = self.client.get(reverse(url_name), params, HTTP_ACCEPT="text/html")
|
||||
|
||||
enterprise_sidebar_div_id = u'enterprise-content-container'
|
||||
|
||||
@@ -453,7 +459,10 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
|
||||
self.assertNotContains(response, text=enterprise_sidebar_div_id)
|
||||
else:
|
||||
self.assertContains(response, text=enterprise_sidebar_div_id)
|
||||
welcome_message = settings.ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE
|
||||
if is_proxy:
|
||||
welcome_message = settings.ENTERPRISE_PROXY_LOGIN_WELCOME_TEMPLATE
|
||||
else:
|
||||
welcome_message = settings.ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE
|
||||
expected_message = Text(welcome_message).format(
|
||||
start_bold=HTML('<b>'),
|
||||
end_bold=HTML('</b>'),
|
||||
|
||||
@@ -450,7 +450,7 @@ def enterprise_customer_for_request(request):
|
||||
Check all the context clues of the request to determine if
|
||||
the request being made is tied to a particular EnterpriseCustomer.
|
||||
"""
|
||||
if 'enterprise_customer' in request.session:
|
||||
if 'enterprise_customer' in request.session and request.session['enterprise_customer']:
|
||||
return enterprise_customer_from_cache(request=request)
|
||||
else:
|
||||
enterprise_customer = enterprise_customer_from_api(request)
|
||||
|
||||
@@ -51,7 +51,8 @@ def update_logistration_context_for_enterprise(request, context, enterprise_cust
|
||||
"""
|
||||
sidebar_context = {}
|
||||
if enterprise_customer:
|
||||
sidebar_context = get_enterprise_sidebar_context(enterprise_customer)
|
||||
is_proxy_login = request.GET.get('proxy_login')
|
||||
sidebar_context = get_enterprise_sidebar_context(enterprise_customer, is_proxy_login)
|
||||
|
||||
if sidebar_context:
|
||||
context['data']['registration_form_desc']['fields'] = enterprise_fields_only(
|
||||
@@ -67,7 +68,7 @@ def update_logistration_context_for_enterprise(request, context, enterprise_cust
|
||||
update_third_party_auth_context_for_enterprise(request, context, enterprise_customer)
|
||||
|
||||
|
||||
def get_enterprise_sidebar_context(enterprise_customer):
|
||||
def get_enterprise_sidebar_context(enterprise_customer, is_proxy_login):
|
||||
"""
|
||||
Get context information for enterprise sidebar for the given enterprise customer.
|
||||
|
||||
@@ -84,10 +85,16 @@ def get_enterprise_sidebar_context(enterprise_customer):
|
||||
branding_configuration = enterprise_customer.get('branding_configuration', {})
|
||||
logo_url = branding_configuration.get('logo', '') if isinstance(branding_configuration, dict) else ''
|
||||
|
||||
branded_welcome_template = configuration_helpers.get_value(
|
||||
'ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE',
|
||||
settings.ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE
|
||||
)
|
||||
if is_proxy_login:
|
||||
branded_welcome_template = configuration_helpers.get_value(
|
||||
'ENTERPRISE_PROXY_LOGIN_WELCOME_TEMPLATE',
|
||||
settings.ENTERPRISE_PROXY_LOGIN_WELCOME_TEMPLATE
|
||||
)
|
||||
else:
|
||||
branded_welcome_template = configuration_helpers.get_value(
|
||||
'ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE',
|
||||
settings.ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE
|
||||
)
|
||||
|
||||
branded_welcome_string = Text(branded_welcome_template).format(
|
||||
start_bold=HTML('<b>'),
|
||||
|
||||
Reference in New Issue
Block a user