diff --git a/core/admin/mailu/ui/forms.py b/core/admin/mailu/ui/forms.py index 9967fefc..b6b6f34e 100644 --- a/core/admin/mailu/ui/forms.py +++ b/core/admin/mailu/ui/forms.py @@ -169,7 +169,7 @@ class FetchForm(flask_wtf.FlaskForm): port = fields.IntegerField(_('TCP port'), [validators.DataRequired(), validators.NumberRange(min=0, max=65535)]) tls = fields.BooleanField(_('Enable TLS')) username = fields.StringField(_('Username'), [validators.DataRequired()]) - password = fields.PasswordField(_('Password'), [validators.DataRequired()]) + password = fields.PasswordField(_('Password')) keep = fields.BooleanField(_('Keep emails on the server')) submit = fields.SubmitField(_('Submit')) diff --git a/core/admin/mailu/ui/views/fetches.py b/core/admin/mailu/ui/views/fetches.py index d9f55404..f2049fe9 100644 --- a/core/admin/mailu/ui/views/fetches.py +++ b/core/admin/mailu/ui/views/fetches.py @@ -3,6 +3,7 @@ from mailu.ui import ui, forms, access import flask import flask_login +import wtforms @ui.route('/fetch/list', methods=['GET', 'POST'], defaults={'user_email': None}) @@ -21,6 +22,7 @@ def fetch_create(user_email): user_email = user_email or flask_login.current_user.email user = models.User.query.get(user_email) or flask.abort(404) form = forms.FetchForm() + form.pw.validators = [wtforms.validators.DataRequired()] if form.validate_on_submit(): fetch = models.Fetch(user=user) form.populate_obj(fetch) @@ -38,6 +40,8 @@ def fetch_edit(fetch_id): fetch = models.Fetch.query.get(fetch_id) or flask.abort(404) form = forms.FetchForm(obj=fetch) if form.validate_on_submit(): + if not form.password.data: + form.password.data = fetch.password form.populate_obj(fetch) models.db.session.commit() flask.flash('Fetch configuration updated')