middleware: Use request.user for logging when possible.

Instead of trying to set the _requestor_for_logs attribute in all the
relevant places, we try to use request.user when possible (that will be
when it's a UserProfile or RemoteZulipServer as of now). In other
places, we set _requestor_for_logs to avoid manually editing the
request.user attribute, as it should mostly be left for Django to manage
it.
In places where we remove the "request._requestor_for_logs = ..." line,
it is clearly implied by the previous code (or the current surrounding
code) that request.user is of the correct type.
This commit is contained in:
Mateusz Mandera
2020-03-09 12:21:46 +01:00
committed by Tim Abbott
parent 0255ca9b6a
commit 89394fc1eb
6 changed files with 9 additions and 10 deletions

View File

@@ -280,7 +280,6 @@ class HostRequestMock:
self.method = ''
self.body = ''
self.content_type = ''
self._requestor_for_logs = ''
def get_host(self) -> str:
return self.host