@@ -61,7 +61,7 @@ from openedx.core.djangoapps.user_api.accounts.toggles import should_redirect_to
% endif
% if should_redirect_to_logistration_mfe:
diff --git a/openedx/core/djangoapps/user_api/accounts/toggles.py b/openedx/core/djangoapps/user_api/accounts/toggles.py
index 5bb2f019b5..621d13048d 100644
--- a/openedx/core/djangoapps/user_api/accounts/toggles.py
+++ b/openedx/core/djangoapps/user_api/accounts/toggles.py
@@ -2,8 +2,6 @@
Toggles for accounts related code.
"""
-from django.conf import settings
-
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.waffle_utils import WaffleFlag
@@ -44,10 +42,3 @@ def should_redirect_to_account_microfrontend():
configuration_helpers.get_value('ENABLE_ACCOUNT_MICROFRONTEND') and
REDIRECT_TO_ACCOUNT_MICROFRONTEND.is_enabled()
)
-
-
-def should_redirect_to_logistration_mircrofrontend():
- return (
- should_redirect_to_account_microfrontend() and
- settings.FEATURES.get('ENABLE_LOGISTRATION_MICROFRONTEND')
- )
diff --git a/openedx/core/djangoapps/user_authn/utils.py b/openedx/core/djangoapps/user_authn/utils.py
index 2ed90062f1..fb40374a85 100644
--- a/openedx/core/djangoapps/user_authn/utils.py
+++ b/openedx/core/djangoapps/user_authn/utils.py
@@ -11,6 +11,8 @@ from django.utils import http
from oauth2_provider.models import Application
from six.moves.urllib.parse import urlparse # pylint: disable=import-error
+from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
+
def is_safe_login_or_logout_redirect(redirect_to, request_host, dot_client_id, require_https):
"""
@@ -67,3 +69,12 @@ def is_registration_api_v1(request):
:return: Bool
"""
return 'v1' in request.get_full_path() and 'register' not in request.get_full_path()
+
+
+def should_redirect_to_logistration_mircrofrontend():
+ """
+ Checks if login/registration should be done via MFE.
+ """
+ return configuration_helpers.get_value(
+ 'ENABLE_LOGISTRATION_MICROFRONTEND', settings.FEATURES.get('ENABLE_LOGISTRATION_MICROFRONTEND')
+ )
diff --git a/openedx/core/djangoapps/user_authn/views/login.py b/openedx/core/djangoapps/user_authn/views/login.py
index 638ca779d7..384f33e8e6 100644
--- a/openedx/core/djangoapps/user_authn/views/login.py
+++ b/openedx/core/djangoapps/user_authn/views/login.py
@@ -31,10 +31,10 @@ from rest_framework.views import APIView
from edxmako.shortcuts import render_to_response
from openedx.core.djangoapps.password_policy import compliance as password_policy_compliance
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
-from openedx.core.djangoapps.user_api.accounts.toggles import should_redirect_to_logistration_mircrofrontend
from openedx.core.djangoapps.user_authn.views.login_form import get_login_session_form
from openedx.core.djangoapps.user_authn.cookies import refresh_jwt_cookies, set_logged_in_cookies
from openedx.core.djangoapps.user_authn.exceptions import AuthFailedError
+from openedx.core.djangoapps.user_authn.utils import should_redirect_to_logistration_mircrofrontend
from openedx.core.djangoapps.util.user_messages import PageLevelMessages
from openedx.core.djangoapps.user_authn.views.password_reset import send_password_reset_email_for_user
from openedx.core.djangoapps.user_authn.config.waffle import ENABLE_LOGIN_USING_THIRDPARTY_AUTH_ONLY
diff --git a/openedx/core/djangoapps/user_authn/views/login_form.py b/openedx/core/djangoapps/user_authn/views/login_form.py
index 67f0f6e152..c5ec46d835 100644
--- a/openedx/core/djangoapps/user_authn/views/login_form.py
+++ b/openedx/core/djangoapps/user_authn/views/login_form.py
@@ -18,13 +18,13 @@ import third_party_auth
from edxmako.shortcuts import render_to_response
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.user_api import accounts
-from openedx.core.djangoapps.user_api.accounts.toggles import should_redirect_to_logistration_mircrofrontend
from openedx.core.djangoapps.user_api.accounts.utils import (
is_multiple_user_enterprises_feature_enabled,
is_secondary_email_feature_enabled
)
from openedx.core.djangoapps.user_api.helpers import FormDescription
from openedx.core.djangoapps.user_authn.cookies import are_logged_in_cookies_set
+from openedx.core.djangoapps.user_authn.utils import should_redirect_to_logistration_mircrofrontend
from openedx.core.djangoapps.user_authn.views.password_reset import get_password_reset_form
from openedx.core.djangoapps.user_authn.views.registration_form import RegistrationFormFactory
from openedx.features.enterprise_support.api import enterprise_customer_for_request
@@ -189,7 +189,7 @@ def login_and_registration_form(request, initial_mode="login"):
initial_mode,
'?' + query_params if query_params else ''
)
- return redirect(settings.ACCOUNT_MICROFRONTEND_URL + url_path)
+ return redirect(settings.LOGISTRATION_MICROFRONTEND_URL + url_path)
# Account activation message
account_activation_messages = [
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 718d213363..df89781a19 100644
--- a/openedx/core/djangoapps/user_authn/views/tests/test_login.py
+++ b/openedx/core/djangoapps/user_authn/views/tests/test_login.py
@@ -25,7 +25,6 @@ from openedx.core.djangoapps.password_policy.compliance import (
NonCompliantPasswordWarning
)
from openedx.core.djangoapps.user_api.accounts import EMAIL_MIN_LENGTH, EMAIL_MAX_LENGTH
-from openedx.core.djangoapps.user_api.accounts.toggles import REDIRECT_TO_ACCOUNT_MICROFRONTEND
from openedx.core.djangoapps.user_authn.cookies import jwt_cookies
from openedx.core.djangoapps.user_authn.views.login import (
AllowedAuthUser,
@@ -35,7 +34,6 @@ from openedx.core.djangoapps.user_authn.views.login import (
from openedx.core.djangoapps.user_authn.tests.utils import setup_login_oauth_client
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
-from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag
from openedx.core.lib.api.test_utils import ApiTestCase
from student.tests.factories import RegistrationFactory, UserFactory, UserProfileFactory
from util.password_policy_validators import DEFAULT_MAX_PASSWORD_LENGTH
@@ -142,8 +140,6 @@ class LoginTest(SiteMixin, CacheIsolationTestCase):
@override_settings(FEATURES=FEATURES_WITH_LOGIN_MFE_ENABLED)
@skip_unless_lms
def test_login_success_with_redirect(self, next_url, course_id, expected_redirect):
- site_domain = 'example.org'
- self.set_up_site(site_domain, {'ENABLE_ACCOUNT_MICROFRONTEND': True})
post_params = {}
if next_url:
@@ -151,13 +147,12 @@ class LoginTest(SiteMixin, CacheIsolationTestCase):
if course_id:
post_params['course_id'] = course_id
- with override_waffle_flag(REDIRECT_TO_ACCOUNT_MICROFRONTEND, active=True):
- response, _ = self._login_response(
- self.user_email,
- self.password,
- extra_post_params=post_params,
- HTTP_ACCEPT='*/*',
- )
+ response, _ = self._login_response(
+ self.user_email,
+ self.password,
+ extra_post_params=post_params,
+ HTTP_ACCEPT='*/*',
+ )
self._assert_response(response, success=True)
self._assert_redirect_url(response, expected_redirect)
diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py b/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py
index 35787b8105..04ac77b0a2 100644
--- a/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py
+++ b/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py
@@ -27,9 +27,7 @@ from lms.djangoapps.branding.api import get_privacy_url
from openedx.core.djangoapps.site_configuration.tests.factories import SiteConfigurationFactory, SiteFactory
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme_context
-from openedx.core.djangoapps.user_api.accounts.toggles import REDIRECT_TO_ACCOUNT_MICROFRONTEND
from openedx.core.djangoapps.user_authn.views.login_form import login_and_registration_form
-from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag
from openedx.core.djangolib.js_utils import dump_js_escaped_json
from openedx.core.djangolib.markup import HTML, Text
from openedx.core.djangolib.testing.utils import skip_unless_lms
@@ -40,7 +38,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
@skip_unless_lms
@ddt.ddt
-class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleStoreTestCase, SiteMixin):
+class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleStoreTestCase):
""" Tests for Login and Registration. """
USERNAME = "bob"
EMAIL = "bob@example.com"
@@ -82,13 +80,9 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
Test that if Logistration MFE is enabled, then we redirect to
the correct URL.
"""
- site_domain = 'example.org'
- self.set_up_site(site_domain, {'ENABLE_ACCOUNT_MICROFRONTEND': True})
+ response = self.client.get(reverse(url_name))
- with override_waffle_flag(REDIRECT_TO_ACCOUNT_MICROFRONTEND, active=True):
- response = self.client.get(reverse(url_name))
-
- self.assertEqual(response.url, settings.ACCOUNT_MICROFRONTEND_URL + path)
+ self.assertEqual(response.url, settings.LOGISTRATION_MICROFRONTEND_URL + path)
self.assertEqual(response.status_code, 302)
@ddt.data(
@@ -110,15 +104,10 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
Test that if request is redirected to logistration MFE,
query params are passed to the redirect url.
"""
- site_domain = 'example.org'
- expected_url = settings.ACCOUNT_MICROFRONTEND_URL + path + '?' + urlencode(query_params)
+ expected_url = settings.LOGISTRATION_MICROFRONTEND_URL + path + '?' + urlencode(query_params)
+ response = self.client.get(reverse(url_name), query_params)
- self.set_up_site(site_domain, {'ENABLE_ACCOUNT_MICROFRONTEND': True})
-
- with override_waffle_flag(REDIRECT_TO_ACCOUNT_MICROFRONTEND, active=True):
- response = self.client.get(reverse(url_name), query_params)
-
- self.assertRedirects(response, expected_url)
+ self.assertRedirects(response, expected_url, target_status_code=302)
@ddt.data(
("signin_user", "login"),
diff --git a/themes/edx.org/lms/templates/header/navbar-not-authenticated.html b/themes/edx.org/lms/templates/header/navbar-not-authenticated.html
index f4630e5b96..ae8b0ff27e 100644
--- a/themes/edx.org/lms/templates/header/navbar-not-authenticated.html
+++ b/themes/edx.org/lms/templates/header/navbar-not-authenticated.html
@@ -23,7 +23,7 @@ from six import text_type
% if allow_public_account_creation:
% if should_redirect_to_logistration_mfe:
% else:
@@ -33,7 +33,7 @@ from six import text_type
% endif
% if should_redirect_to_logistration_mfe:
% else: