Skip to content

Commit

Permalink
Merge pull request #430 from ucsd-ets/umerF/ede-917/add-event-logout
Browse files Browse the repository at this point in the history
Added edx.user.logout Event
  • Loading branch information
mumerfarooq000 authored Sep 24, 2020
2 parents 66ca95d + 2d4202d commit 4e56483
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 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,21 @@ 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, [])

# if tests are giving Anonymous User objects
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)

if request.user.is_anonymous:
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 4e56483

Please sign in to comment.