From 1d09abddebff8c31be73e4d155163a2367cedec4 Mon Sep 17 00:00:00 2001 From: Daniyal Farman <122009873+daniyalfarman@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:58:15 +0500 Subject: [PATCH] fixed redirect url (#495) --- cms/djangoapps/contentstore/views/course.py | 7 ++++++- .../djangoapps/user_authn/views/logout.py | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 521f37bc0b96..9862f01925d6 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -631,9 +631,14 @@ def format_library_for_view(library): frontend_url = [url for url in settings.CORS_ORIGIN_WHITELIST if 'apps' in url] if len(frontend_url): frontent_redirect_url = '{}/panel/settings/billing'.format(frontend_url[0]) + + try: + destination_course_id = DESTINATION_COURSE_ID_PATTERN.format(org[0]) + except Exception: + destination_course_id = "dummy" return render_to_response(u'index.html', { - u'default_course_id': DESTINATION_COURSE_ID_PATTERN.format(org[0]), + u'default_course_id': destination_course_id, u'tracking_api_url': tracking_api_url, u'courses': active_courses, u'archived_courses': archived_courses, diff --git a/openedx/core/djangoapps/user_authn/views/logout.py b/openedx/core/djangoapps/user_authn/views/logout.py index f7979130b1d3..849fd450234e 100644 --- a/openedx/core/djangoapps/user_authn/views/logout.py +++ b/openedx/core/djangoapps/user_authn/views/logout.py @@ -12,6 +12,8 @@ from six.moves.urllib.parse import parse_qs, urlsplit, urlunsplit # pylint: disable=import-error from lms.envs.common import EDLY_PANEL_ADMIN_USERS_GROUP +from openedx.features.edly.models import EdlyMultiSiteAccess +from openedx.features.edly.utils import get_edly_sub_org_from_request from openedx.core.djangoapps.user_authn.cookies import delete_logged_in_cookies from openedx.core.djangoapps.user_authn.utils import is_safe_login_or_logout_redirect from common.djangoapps.third_party_auth import pipeline as tpa_pipeline @@ -76,17 +78,24 @@ def target(self): require_https=self.request.is_secure(), ) - if use_target_url: - return target_url - if self.is_user_panel_admin: return settings.PANEL_ADMIN_LOGOUT_REDIRECT_URL + if use_target_url: + return target_url + return self.default_target def dispatch(self, request, *args, **kwargs): - if request.user.groups.filter(name=EDLY_PANEL_ADMIN_USERS_GROUP): - self.is_user_panel_admin = True + sub_org = get_edly_sub_org_from_request(request) + if request.user.is_authenticated: + edly_multisite_access = EdlyMultiSiteAccess.objects.filter( + sub_org=sub_org, + user=request.user, + groups__name=EDLY_PANEL_ADMIN_USERS_GROUP + ) + if edly_multisite_access.exists(): + self.is_user_panel_admin = True # We do not log here, because we have a handler registered to perform logging on successful logouts. request.is_from_logout = True