Przeglądaj źródła

refactor(api): small BasicTokenAuthentication performance improvement

Peter Thomassen 4 lat temu
rodzic
commit
374fe294f2
1 zmienionych plików z 1 dodań i 2 usunięć
  1. 1 2
      api/desecapi/authentication.py

+ 1 - 2
api/desecapi/authentication.py

@@ -94,8 +94,7 @@ class BasicTokenAuthentication(BaseAuthentication):
         try:
             username, key = base64.b64decode(basic).decode(HTTP_HEADER_ENCODING).split(':')
             user, token = TokenAuthentication().authenticate_credentials(key)
-            domain_names = user.domains.values_list('name', flat=True)
-            if username not in ['', user.email] and not username.lower() in domain_names:
+            if username not in ['', user.email] and not user.domains.filter(name=username.lower()).exists():
                 raise Exception
         except Exception:
             raise exceptions.AuthenticationFailed(invalid_token_message)