Исправил get_current_user()

This commit is contained in:
Viner Abubakirov
2026-01-04 12:11:42 +05:00
parent 2d3878c8ba
commit 6c75b1ee7f

View File

@@ -1,5 +1,6 @@
import threading import threading
from django.utils.deprecation import MiddlewareMixin from django.utils.deprecation import MiddlewareMixin
from django.contrib.auth.models import AnonymousUser
_thread_local = threading.local() _thread_local = threading.local()
@@ -14,7 +15,9 @@ def get_current_user():
"""Retrieve the user from the current request.""" """Retrieve the user from the current request."""
request = get_current_request() request = get_current_request()
if request: if request:
return getattr(request, "user", None) user = getattr(request, "user", None)
if not isinstance(user, AnonymousUser):
return user
return None return None