From 89e3d189ca9c29d98378baa8a026a2833d1cd820 Mon Sep 17 00:00:00 2001 From: Javier Ontiveros Date: Mon, 9 Jun 2025 09:12:08 -0600 Subject: [PATCH] fix: strip end slash if any when using a subpath (#36870) While trying to be enrolled on a verified course, the upgrade process gets to an error screen due to a double slash on the URL that it's added while doing the redirection to the account microfrontend Will be backported to Teak. Part of https://github.com/openedx/wg-build-test-release/issues/468 --- .../management/commands/send_verification_expiry_email.py | 3 ++- lms/djangoapps/verify_student/services.py | 3 ++- lms/djangoapps/verify_student/views.py | 3 ++- openedx/core/djangoapps/notifications/email/utils.py | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py b/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py index 04f75ef424..7902990fcc 100644 --- a/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py +++ b/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py @@ -188,10 +188,11 @@ class Command(BaseCommand): return True site = Site.objects.get_current() + account_base_url = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/') message_context = get_base_template_context(site) message_context.update({ 'platform_name': settings.PLATFORM_NAME, - 'lms_verification_link': f'{settings.ACCOUNT_MICROFRONTEND_URL}/id-verification', + 'lms_verification_link': f'{account_base_url}/id-verification', 'help_center_link': settings.ID_VERIFICATION_SUPPORT_LINK }) diff --git a/lms/djangoapps/verify_student/services.py b/lms/djangoapps/verify_student/services.py index 95dbccf0d5..4091532bd0 100644 --- a/lms/djangoapps/verify_student/services.py +++ b/lms/djangoapps/verify_student/services.py @@ -251,7 +251,8 @@ class IDVerificationService: Returns a string: Returns URL for IDV on Account Microfrontend """ - location = f'{settings.ACCOUNT_MICROFRONTEND_URL}/id-verification' + account_base_url = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/') + location = f'{account_base_url}/id-verification' if course_id: location += f'?course_id={quote(str(course_id))}' diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index 1b6a47bee8..0552611902 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -1128,7 +1128,8 @@ def results_callback(request): # lint-amnesty, pylint: disable=too-many-stateme log.info("[COSMO-184] Denied verification for receipt_id={receipt_id}.".format(receipt_id=receipt_id)) attempt.deny(json.dumps(reason), error_code=error_code) - reverify_url = f'{settings.ACCOUNT_MICROFRONTEND_URL}/id-verification' + account_base_url = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/') + reverify_url = f'{account_base_url}/id-verification' verification_status_email_vars['reasons'] = reason verification_status_email_vars['reverify_url'] = reverify_url verification_status_email_vars['faq_url'] = settings.ID_VERIFICATION_SUPPORT_LINK diff --git a/openedx/core/djangoapps/notifications/email/utils.py b/openedx/core/djangoapps/notifications/email/utils.py index d0a5a8e0d6..b56b3fe97b 100644 --- a/openedx/core/djangoapps/notifications/email/utils.py +++ b/openedx/core/djangoapps/notifications/email/utils.py @@ -97,13 +97,14 @@ def create_email_template_context(username): 'channel': 'email', 'value': False } + account_base_url = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/') return { "platform_name": settings.PLATFORM_NAME, "mailing_address": settings.CONTACT_MAILING_ADDRESS, "logo_url": get_logo_url_for_email(), "logo_notification_cadence_url": settings.NOTIFICATION_DIGEST_LOGO, "social_media": social_media_info, - "notification_settings_url": f"{settings.ACCOUNT_MICROFRONTEND_URL}/#notifications", + "notification_settings_url": f"{account_base_url}/#notifications", "unsubscribe_url": get_unsubscribe_link(username, patch) }