Skip to content

Commit

Permalink
Merge pull request #432 from ucsd-ets/danial/check-for-anonymous-user…
Browse files Browse the repository at this point in the history
…-on-logout-event

Don't emit logout event for already anonymous user
  • Loading branch information
Danial Malik authored Sep 30, 2020
2 parents 4e56483 + 8267e5c commit c6bd37b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions openedx/core/djangoapps/user_authn/views/logout.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ 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 = {
Expand All @@ -67,7 +66,10 @@ def dispatch(self, request, *args, **kwargs):

logout(request)

if request.user.is_anonymous:
# `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)

Expand Down

0 comments on commit c6bd37b

Please sign in to comment.