From 7f06e72f5e10b032e00a58e171838e97bd1d9b69 Mon Sep 17 00:00:00 2001 From: Syed Sajjad Hussain Shah <52817156+syedsajjadkazmii@users.noreply.github.com> Date: Mon, 7 Aug 2023 10:09:55 +0500 Subject: [PATCH] fix: redirection issue with enterprise selection page flow (#32909) VAN-1511 --- openedx/core/djangoapps/user_authn/views/login.py | 2 +- openedx/core/djangoapps/user_authn/views/tests/test_login.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/user_authn/views/login.py b/openedx/core/djangoapps/user_authn/views/login.py index 79cb78a2727c..fa098c7237db 100644 --- a/openedx/core/djangoapps/user_authn/views/login.py +++ b/openedx/core/djangoapps/user_authn/views/login.py @@ -469,7 +469,7 @@ def enterprise_selection_page(request, user, next_url): response = get_enterprise_learner_data_from_api(user) if response and len(response) > 1: - redirect_url = reverse('enterprise_select_active') + '/?success_url=' + next_url + redirect_url = reverse('enterprise_select_active') + '/?success_url=' + urllib.parse.quote(next_url) # Check to see if next url has an enterprise in it. In this case if user is associated with # that enterprise, activate that enterprise and bypass the selection page. diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_login.py b/openedx/core/djangoapps/user_authn/views/tests/test_login.py index 10ef1312fb25..1e8a4c3ed510 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_login.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_login.py @@ -7,6 +7,7 @@ import hashlib import json import unicodedata +import urllib.parse from unittest.mock import Mock, patch import ddt @@ -312,6 +313,9 @@ def test_enterprise_in_url( HTTP_ACCEPT='*/*', ) + if not is_activated: + next_url = urllib.parse.quote(next_url) + self._assert_response(response, success=True) self._assert_redirect_url(response, settings.LMS_ROOT_URL + expected_redirect + next_url)