From 98e135d0c6bcfd01ee80a84b111b7878602282dc Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 10 Mar 2016 21:28:31 +0100 Subject: [PATCH] Fixes #127 -- Leave SMTP password unchanged if not provided --- src/pretix/control/forms/event.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pretix/control/forms/event.py b/src/pretix/control/forms/event.py index 77015fae61..1d4da9ff48 100644 --- a/src/pretix/control/forms/event.py +++ b/src/pretix/control/forms/event.py @@ -264,6 +264,14 @@ class MailSettingsForm(SettingsForm): required=False ) + def clean(self): + data = self.cleaned_data + if not data.get('smtp_password') and data.get('smtp_username'): + # Leave password unchanged if the username is set and the password field is empty. + # This makes it impossible to set an empty password as long as a username is set, but + # Python's smtplib does not support password-less schemes anyway. + data['smtp_password'] = self.initial.get('smtp_password') + class TicketSettingsForm(SettingsForm): ticket_download = forms.BooleanField(