add handler on user not found exception

This commit is contained in:
Timur
2025-03-01 23:24:48 +03:00
parent 3a33f0dfc9
commit 7e4012bf09
+3
View File
@@ -19,7 +19,10 @@ class BearerAuth(HttpBearer):
except Exception: except Exception:
raise AuthenticationError raise AuthenticationError
try:
user = User.objects.get(id=data["id"]) user = User.objects.get(id=data["id"])
except User.DoesNotExist:
raise AuthenticationError
return user return user
@staticmethod @staticmethod