Skip to content

Commit

Permalink
Merge pull request #434 from ucsd-ets/develop
Browse files Browse the repository at this point in the history
release-2020-09-28
  • Loading branch information
Danial Malik authored Sep 30, 2020
2 parents c8afc14 + c6bd37b commit 36ca1b3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions openedx/core/djangoapps/user_authn/views/logout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from urlparse import parse_qs, urlsplit, urlunsplit

import edx_oauth2_provider
from eventtracking import tracker
from django.conf import settings
from django.contrib.auth import logout
from django.urls import reverse_lazy
Expand Down Expand Up @@ -55,8 +56,23 @@ def dispatch(self, request, *args, **kwargs):
# Get the list of authorized clients before we clear the session.
self.oauth_client_ids = request.session.get(edx_oauth2_provider.constants.AUTHORIZED_CLIENTS_SESSION_KEY, [])

event_data = {}
if not request.user.is_anonymous:
event_data = {
'email': request.POST.get('email'),
'username': request.user.username,
'user_id': request.user.id
}

logout(request)

# `event_data` will be empty if the user was anonymous even before
# the `logout` call. don't emit event if an anonymous user has hit
# the logout URL.
if request.user.is_anonymous and event_data:
event_name = 'edx.user.logout'
tracker.emit(event_name, event_data)

# If we are using studio logout directly and there is not OIDC logouts we can just redirect the user
if settings.FEATURES.get('DISABLE_STUDIO_SSO_OVER_LMS', False) and not self.oauth_client_ids:
response = redirect(self.target)
Expand Down

0 comments on commit 36ca1b3

Please sign in to comment.