Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

rate_limit: Delete code handling impossible cases with request.user.

Mateusz Manderac00aab8ede9a
diff --git a/zerver/decorator.py b/zerver/decorator.py
index 3a51fad7cbb..24990a8a1aa 100644
--- a/zerver/decorator.py
+++ b/zerver/decorator.py
@@ -787,17 +787,7 @@ def rate_limit(domain: str='api_by_user') -> Callable[[ViewFuncT], ViewFuncT]:
if client_is_exempt_from_rate_limiting(request):
return func(request, *args, **kwargs)
- try:
- user = request.user
- except Exception: # nocoverage # See comments below
- # TODO: This logic is not tested, and I'm not sure we are
- # doing the right thing here.
- user = None
-
- if not user: # nocoverage # See comments below
- logging.error("Requested rate-limiting on %s but user is not authenticated!",
- func.__name__)
- return func(request, *args, **kwargs)
+ user = request.user
if isinstance(user, AnonymousUser): # nocoverage
# We can only rate-limit logged-in users for now.