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:
@@ -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