Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Redirect User To Panel When Logging Out In Case Of Panel Admin #495

Merged
merged 1 commit into from
Jan 18, 2024
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
7 changes: 6 additions & 1 deletion cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 14 additions & 5 deletions openedx/core/djangoapps/user_authn/views/logout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down