Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,8 @@
# .. toggle_creation_date: 2020-09-08
# .. toggle_target_removal_date: None
# .. toggle_tickets: 'https://github.com/edx/edx-platform/pull/24908'
# .. toggle_warnings: Also set settings.ACCOUNT_MICROFRONTEND_URL and set REDIRECT_TO_ACCOUNT_MICROFRONTEND for
# rollout. This temporary feature toggle does not have a target removal date.
# .. toggle_warnings: Also set settings.LOGISTRATION_MICROFRONTEND_URL for rollout. This temporary feature
# toggle does not have a target removal date.
'ENABLE_LOGISTRATION_MICROFRONTEND': False,

### ORA Feature Flags ###
Expand Down Expand Up @@ -4000,6 +4000,7 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
PROFILE_MICROFRONTEND_URL = None
ORDER_HISTORY_MICROFRONTEND_URL = None
ACCOUNT_MICROFRONTEND_URL = None
LOGISTRATION_MICROFRONTEND_URL = None
PROGRAM_CONSOLE_MICROFRONTEND_URL = None
LEARNING_MICROFRONTEND_URL = None

Expand Down
1 change: 1 addition & 0 deletions lms/envs/devstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def should_show_debug_toolbar(request):
############## Settings for Microfrontends #########################
LEARNING_MICROFRONTEND_URL = 'http://localhost:2000'
ACCOUNT_MICROFRONTEND_URL = 'http://localhost:1997'
LOGISTRATION_MICROFRONTEND_URL = 'http://localhost:1999'

############## Docker based devstack settings #######################

Expand Down
1 change: 1 addition & 0 deletions lms/envs/devstack_decentralized.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def should_show_debug_toolbar(request):
############## Settings for Microfrontends #########################
LEARNING_MICROFRONTEND_URL = 'http://localhost:2000'
ACCOUNT_MICROFRONTEND_URL = 'http://localhost:1997'
LOGISTRATION_MICROFRONTEND_URL = 'http://localhost:1999'

############## Docker based devstack settings #######################

Expand Down
1 change: 1 addition & 0 deletions lms/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@
PROFILE_MICROFRONTEND_URL = "http://profile-mfe/abc/"
ORDER_HISTORY_MICROFRONTEND_URL = "http://order-history-mfe/"
ACCOUNT_MICROFRONTEND_URL = "http://account-mfe/"
LOGISTRATION_MICROFRONTEND_URL = "http://logistation-mfe"
LEARNING_MICROFRONTEND_URL = "http://learning-mfe"

########################## limiting dashboard courses ######################
Expand Down
6 changes: 3 additions & 3 deletions lms/templates/header/navbar-not-authenticated.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.utils.translation import ugettext as _
from six import text_type

from openedx.core.djangoapps.user_api.accounts.toggles import should_redirect_to_logistration_mircrofrontend
from openedx.core.djangoapps.user_authn.utils import should_redirect_to_logistration_mircrofrontend
%>

<%
Expand Down Expand Up @@ -51,7 +51,7 @@
% if allow_public_account_creation:
% if should_redirect_to_logistration_mfe:
<div class="mobile-nav-item hidden-mobile nav-item">
<a class="register-btn btn" href="${settings.ACCOUNT_MICROFRONTEND_URL}/register${login_query()}">${_("Register")}</a>
<a class="register-btn btn" href="${settings.LOGISTRATION_MICROFRONTEND_URL}/register${login_query()}">${_("Register")}</a>
</div>
% else:
<div class="mobile-nav-item hidden-mobile nav-item">
Expand All @@ -61,7 +61,7 @@
% endif
% if should_redirect_to_logistration_mfe:
<div class="mobile-nav-item hidden-mobile nav-item">
<a class="sign-in-btn btn" href="${settings.ACCOUNT_MICROFRONTEND_URL}/login${login_query()}">${_("Sign in")}</a>
<a class="sign-in-btn btn" href="${settings.LOGISTRATION_MICROFRONTEND_URL}/login${login_query()}">${_("Sign in")}</a>
</div>
% else:
<div class="mobile-nav-item hidden-mobile nav-item">
Expand Down
9 changes: 0 additions & 9 deletions openedx/core/djangoapps/user_api/accounts/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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')
)
11 changes: 11 additions & 0 deletions openedx/core/djangoapps/user_authn/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
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):
"""
Expand Down Expand Up @@ -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')
)
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/user_authn/views/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
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
Expand Down
4 changes: 2 additions & 2 deletions openedx/core/djangoapps/user_authn/views/login_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
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
Expand Down Expand Up @@ -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 = [
Expand Down
17 changes: 6 additions & 11 deletions openedx/core/djangoapps/user_authn/views/tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
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,
Expand All @@ -35,7 +34,6 @@
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
Expand Down Expand Up @@ -142,22 +140,19 @@ def test_login_success(self):
@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:
post_params['next'] = next_url
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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
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
Expand All @@ -40,7 +38,7 @@

@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"
Expand Down Expand Up @@ -82,13 +80,9 @@ def test_logistration_mfe_redirects(self, url_name, path):
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})

with override_waffle_flag(REDIRECT_TO_ACCOUNT_MICROFRONTEND, active=True):
response = self.client.get(reverse(url_name))
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(
Expand All @@ -110,15 +104,10 @@ def test_logistration_redirect_params(self, url_name, path, query_params):
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)

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)
expected_url = settings.LOGISTRATION_MICROFRONTEND_URL + path + '?' + urlencode(query_params)
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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
% if allow_public_account_creation:
% if should_redirect_to_logistration_mfe:
<div class="mobile-nav-item hidden-mobile nav-item">
<a class="register-btn btn" href="${settings.ACCOUNT_MICROFRONTEND_URL}/register${login_query()}">${_("Register")}</a>
<a class="register-btn btn" href="${settings.LOGISTRATION_MICROFRONTEND_URL}/register${login_query()}">${_("Register")}</a>
</div>
% else:
<div class="mobile-nav-item hidden-mobile nav-item">
Expand All @@ -33,7 +33,7 @@
% endif
% if should_redirect_to_logistration_mfe:
<div class="mobile-nav-item hidden-mobile nav-item">
<a class="sign-in-btn btn" href="${settings.ACCOUNT_MICROFRONTEND_URL}/login${login_query()}">${_("Sign in")}</a>
<a class="sign-in-btn btn" href="${settings.LOGISTRATION_MICROFRONTEND_URL}/login${login_query()}">${_("Sign in")}</a>
</div>
% else:
<div class="mobile-nav-item hidden-mobile nav-item">
Expand Down