fix: don't set the correlation_id if the AUDITLOG_CID_GETTER is None (#565)

This commit is contained in:
Abdullah Alaqeel 2023-09-20 13:23:45 +03:00 committed by GitHub
parent 459f4b1521
commit ccc59e85f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -9,7 +9,8 @@
#### Improvements
#### Fixes
* fix: only fire the `post_log` signal when the log is created or when there is an error in the process.
* fix: only fire the `post_log` signal when the log is created or when there is an error in the process ([#561](https://github.com/jazzband/django-auditlog/pull/561))
* fix: don't set the correlation_id if the `AUDITLOG_CID_GETTER` is `None` ([#565](https://github.com/jazzband/django-auditlog/pull/565))
## 3.0.0-beta.1

View file

@ -13,11 +13,16 @@ def set_cid(request: Optional[HttpRequest] = None) -> None:
A function to read the cid from a request.
If the header is not in the request, then we set it to `None`.
Note: we look for the header in `request.headers` and `request.META`.
Note: we look for the value of `AUDITLOG_CID_HEADER` in `request.headers` and in `request.META`.
This function doesn't do anything if the user is supplying their own `AUDITLOG_CID_GETTER`.
:param request: The request to get the cid from.
:return: None
"""
if settings.AUDITLOG_CID_GETTER:
return
cid = None
header = settings.AUDITLOG_CID_HEADER