From 98742268e6bae14dc778ecad69812068bc2038d5 Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Sat, 16 Oct 2021 15:12:20 +0200 Subject: [PATCH] Make it more readable --- core/admin/mailu/internal/views/auth.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/admin/mailu/internal/views/auth.py b/core/admin/mailu/internal/views/auth.py index 2c9a5d31..c5cd9e28 100644 --- a/core/admin/mailu/internal/views/auth.py +++ b/core/admin/mailu/internal/views/auth.py @@ -36,10 +36,12 @@ def nginx_authentication(): response.headers['Auth-Wait'] = '3' return response is_valid_user = True - if headers.get('Auth-Status') != 'OK': - utils.limiter.rate_limit_user(username, client_ip) if is_valid_user else rate_limit_ip(client_ip) - elif headers["Auth-Status"] == "OK": + if headers.get("Auth-Status") == "OK": utils.limiter.exempt_ip_from_ratelimits(client_ip) + elif is_valid_user: + utils.limiter.rate_limit_user(username, client_ip) + else: + rate_limit_ip(client_ip) return response @internal.route("/auth/admin")