Fix HTTP 500 on missing email or domain when creating users and aliases

If the email or domain field was missing or invalid, the error was
flashed, but the address was still built from the unset attributes,
which raised an AttributeError. Only build and validate the address
if both are set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
finnandClaude Opus 5.5 committed 2026-10-21 15:25:38 +00:00
1 parent 4a03b5c1a1
commit 80757fa1d8
2 files changed
+14 -12

No files matched your search

+10 -9
View File
@@ -39,15 +39,16 @@ class AliasCreate(
else:
self.domain = self.get_user_domain()
full_email = f"{self.email}@{self.domain}"
if not self.is_email_valid(full_email):
error = True
elif not self.auth_user.is_admin and self.is_reserved_email(full_email):
flash(
t("This address is reserved and can only be created by an admin."),
category="error",
)
error = True
if not error:
full_email = f"{self.email}@{self.domain}"
if not self.is_email_valid(full_email):
error = True
elif not self.auth_user.is_admin and self.is_reserved_email(full_email):
flash(
t("This address is reserved and can only be created by an admin."),
category="error",
)
error = True
enabled = self.request.form.get("enabled")
if enabled == "on":