Adds Logistration MFE url for forgot password email.
This patch would enable routing learner to logistration MFE via forgot password url than on platform when ENABLE_LOGISTRATION_MICROFRONTEND feature flag is set. VAN-98
This commit is contained in:
@@ -22,6 +22,7 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_
|
||||
from openedx.core.djangoapps.theming.helpers import get_current_site
|
||||
from openedx.core.djangoapps.user_api import accounts as accounts_settings
|
||||
from openedx.core.djangoapps.user_api.accounts.utils import is_secondary_email_feature_enabled
|
||||
from openedx.core.djangoapps.user_authn.utils import should_redirect_to_logistration_mircrofrontend
|
||||
from openedx.core.djangoapps.user_api.preferences.api import get_user_preference
|
||||
from student.message_types import AccountRecovery as AccountRecoveryMessage
|
||||
from student.models import CourseEnrollmentAllowed, email_exists_or_retired
|
||||
@@ -38,13 +39,15 @@ def send_account_recovery_email_for_user(user, request, email=None):
|
||||
"""
|
||||
site = get_current_site()
|
||||
message_context = get_base_template_context(site)
|
||||
site_name = settings.LOGISTRATION_MICROFRONTEND_DOMAIN if should_redirect_to_logistration_mircrofrontend() \
|
||||
else configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME)
|
||||
message_context.update({
|
||||
'request': request, # Used by google_analytics_tracking_pixel
|
||||
'email': email,
|
||||
'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
|
||||
'reset_link': '{protocol}://{site}{link}?is_account_recovery=true'.format(
|
||||
protocol='https' if request.is_secure() else 'http',
|
||||
site=configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME),
|
||||
site=site_name,
|
||||
link=reverse('password_reset_confirm', kwargs={
|
||||
'uidb36': int_to_base36(user.id),
|
||||
'token': default_token_generator.make_token(user),
|
||||
|
||||
@@ -4009,6 +4009,7 @@ PROFILE_MICROFRONTEND_URL = None
|
||||
ORDER_HISTORY_MICROFRONTEND_URL = None
|
||||
ACCOUNT_MICROFRONTEND_URL = None
|
||||
LOGISTRATION_MICROFRONTEND_URL = None
|
||||
LOGISTRATION_MICROFRONTEND_DOMAIN = None
|
||||
PROGRAM_CONSOLE_MICROFRONTEND_URL = None
|
||||
LEARNING_MICROFRONTEND_URL = None
|
||||
|
||||
|
||||
@@ -332,6 +332,7 @@ EDXNOTES_CLIENT_NAME = 'edx_notes_api-backend-service'
|
||||
LEARNING_MICROFRONTEND_URL = 'http://localhost:2000'
|
||||
ACCOUNT_MICROFRONTEND_URL = 'http://localhost:1997'
|
||||
LOGISTRATION_MICROFRONTEND_URL = 'http://localhost:1999'
|
||||
LOGISTRATION_MICROFRONTEND_DOMAIN = 'localhost:1999'
|
||||
|
||||
############## Docker based devstack settings #######################
|
||||
|
||||
|
||||
@@ -572,6 +572,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"
|
||||
LOGISTRATION_MICROFRONTEND_DOMAIN = "logistation-mfe"
|
||||
LEARNING_MICROFRONTEND_URL = "http://learning-mfe"
|
||||
|
||||
########################## limiting dashboard courses ######################
|
||||
|
||||
@@ -34,6 +34,7 @@ from openedx.core.djangoapps.oauth_dispatch.api import destroy_oauth_tokens
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from openedx.core.djangoapps.theming.helpers import get_current_request, get_current_site
|
||||
from openedx.core.djangoapps.user_api import accounts, errors, helpers
|
||||
from openedx.core.djangoapps.user_authn.utils import should_redirect_to_logistration_mircrofrontend
|
||||
from openedx.core.djangoapps.user_api.accounts.utils import is_secondary_email_feature_enabled
|
||||
from openedx.core.djangoapps.user_api.helpers import FormDescription
|
||||
from openedx.core.djangoapps.user_api.models import UserRetirementRequest
|
||||
@@ -145,13 +146,15 @@ def send_password_reset_email_for_user(user, request, preferred_email=None):
|
||||
preferred_email (str): Send email to this address if present, otherwise fallback to user's email address.
|
||||
"""
|
||||
message_context, user_language_preference = get_user_default_email_params(user)
|
||||
site_name = settings.LOGISTRATION_MICROFRONTEND_DOMAIN if should_redirect_to_logistration_mircrofrontend() \
|
||||
else configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME)
|
||||
message_context.update({
|
||||
'request': request, # Used by google_analytics_tracking_pixel
|
||||
# TODO: This overrides `platform_name` from `get_base_template_context` to make the tests passes
|
||||
'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
|
||||
'reset_link': '{protocol}://{site}{link}?track=pwreset'.format(
|
||||
protocol='https' if request.is_secure() else 'http',
|
||||
site=configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME),
|
||||
site=site_name,
|
||||
link=reverse('password_reset_confirm', kwargs={
|
||||
'uidb36': int_to_base36(user.id),
|
||||
'token': default_token_generator.make_token(user),
|
||||
|
||||
@@ -26,7 +26,6 @@ from freezegun import freeze_time
|
||||
from mock import Mock, patch
|
||||
from oauth2_provider import models as dot_models
|
||||
from pytz import UTC
|
||||
from six.moves import range
|
||||
|
||||
from openedx.core.djangoapps.oauth_dispatch.tests import factories as dot_factories
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
@@ -47,6 +46,10 @@ from util.password_policy_validators import create_validator_config
|
||||
from util.testing import EventTestMixin
|
||||
|
||||
|
||||
ENABLE_LOGISTRATION_MICROFRONTEND = settings.FEATURES.copy()
|
||||
ENABLE_LOGISTRATION_MICROFRONTEND['ENABLE_LOGISTRATION_MICROFRONTEND'] = True
|
||||
|
||||
|
||||
def process_request(request):
|
||||
middleware = SessionMiddleware()
|
||||
middleware.process_request(request)
|
||||
@@ -327,6 +330,7 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
|
||||
SETTING_CHANGE_INITIATED, user_id=self.user.id, setting=u'password', old=None, new=None
|
||||
)
|
||||
|
||||
@override_settings(FEATURES=ENABLE_LOGISTRATION_MICROFRONTEND)
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS")
|
||||
@ddt.data(('Crazy Awesome Site', 'Crazy Awesome Site'), ('edX', 'edX'))
|
||||
@ddt.unpack
|
||||
@@ -350,6 +354,7 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
|
||||
reset_msg = reset_msg.format(site_name)
|
||||
|
||||
self.assertIn(reset_msg, msg)
|
||||
self.assertIn(settings.LOGISTRATION_MICROFRONTEND_URL, msg)
|
||||
|
||||
sign_off = u"The {} Team".format(platform_name)
|
||||
self.assertIn(sign_off, msg)
|
||||
|
||||
Reference in New Issue
Block a user