Skip to content
Merged
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
19 changes: 11 additions & 8 deletions common/djangoapps/student/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2596,13 +2596,16 @@ class LogoutView(TemplateView):
oauth_client_ids = []
template_name = 'logout.html'

# Keep track of the page to which the user should ultimately be redirected.
if settings.FEATURES.get('AUTH_USE_CAS'):
target = reverse_lazy('cas-logout')
elif hasattr(settings, 'CUSTOM_LOGOUT_REDIRECT_URL'):
target = settings.CUSTOM_LOGOUT_REDIRECT_URL
else:
target = '/'
def get_target(self):
# Keep track of the page to which the user should ultimately be redirected.
if settings.FEATURES.get('AUTH_USE_CAS'):
target = reverse_lazy('cas-logout')
elif configuration_helpers.get_value('CUSTOM_LOGOUT_REDIRECT_URL', settings.CUSTOM_LOGOUT_REDIRECT_URL):
target = configuration_helpers.get_value('CUSTOM_LOGOUT_REDIRECT_URL', settings.CUSTOM_LOGOUT_REDIRECT_URL)
else:
target = '/'

return target

def dispatch(self, request, *args, **kwargs): # pylint: disable=missing-docstring
# We do not log here, because we have a handler registered to perform logging on successful logouts.
Expand All @@ -2617,7 +2620,7 @@ def dispatch(self, request, *args, **kwargs): # pylint: disable=missing-docstri
if LogoutViewConfiguration.current().enabled and self.oauth_client_ids:
response = super(LogoutView, self).dispatch(request, *args, **kwargs)
else:
response = redirect(self.target)
response = redirect(self.get_target())

# Clear the cookie used by the edx.org marketing site
delete_logged_in_cookies(response)
Expand Down