Skip to content

Commit

Permalink
Fix: request handler, temporary do not get user from thread local. (#146
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jheld authored May 29, 2020
1 parent d1b386f commit d299bb3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions easyaudit/signals/request_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from django.conf import settings
from django.utils.module_loading import import_string

from easyaudit.middleware.easyaudit import get_current_user
# try and get the user from the request; commented for now, may have a bug in this flow.
# from easyaudit.middleware.easyaudit import get_current_user
from easyaudit.settings import REMOTE_ADDR_HEADER, UNREGISTERED_URLS, REGISTERED_URLS, WATCH_REQUEST_EVENTS, \
LOGGING_BACKEND

Expand Down Expand Up @@ -38,8 +39,9 @@ def request_started_handler(sender, environ, **kwargs):
if not should_log_url(environ['PATH_INFO']):
return

# try and get the user from the request
user = get_current_user()
# try and get the user from the request; commented for now, may have a bug in this flow.
# user = get_current_user()
user = None
# get the user from cookies
if not user and environ.get('HTTP_COOKIE'):
cookie = SimpleCookie() # python3 compatibility
Expand Down
2 changes: 2 additions & 0 deletions easyaudit/tests/test_app/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import json
import re
from unittest import skip

from django.test import TestCase, override_settings
from unittest.mock import patch
Expand Down Expand Up @@ -136,6 +137,7 @@ def test_manual_set_user(self):
crud_event = crud_event_qs[0]
self.assertEqual(crud_event.user, None)

@skip("Test may need a rewrite but the library logic has been rolled back.")
def test_middleware_logged_in_user_in_request(self):
user = self._setup_user(TEST_USER_EMAIL, TEST_USER_PASSWORD)
self.client.force_login(user)
Expand Down

0 comments on commit d299bb3

Please sign in to comment.