From f01d8cd9b9b77cfb41b11db40c5f7e9898f6a45c Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Sat, 5 Mar 2022 18:41:06 +0100 Subject: [PATCH] improve --- core/admin/mailu/internal/nginx.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/admin/mailu/internal/nginx.py b/core/admin/mailu/internal/nginx.py index 03142e62..40d72505 100644 --- a/core/admin/mailu/internal/nginx.py +++ b/core/admin/mailu/internal/nginx.py @@ -93,9 +93,8 @@ def handle_authentication(headers): app.logger.warn(f'Received undecodable user/password from nginx: {raw_user_email!r}/{raw_password!r}') else: try: - if '@' in user_email: - user = models.User.query.get(user_email) - is_valid_user = True + user = models.User.query.get(user_email) if '@' in user_email else None + is_valid_user = bool(user) except sqlalchemy.exc.StatementError as exc: exc = str(exc).split('\n', 1)[0] app.logger.warn(f'Invalid user {user_email!r}: {exc}')