1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-12 10:45:38 +02:00

simplify again the logic

This commit is contained in:
Florent Daigniere 2024-07-29 20:33:32 +02:00
parent 9120f731fc
commit f003c0e712
2 changed files with 5 additions and 5 deletions

View File

@ -92,14 +92,12 @@ def user_settings(user_email):
user = models.User.query.get(user_email_or_current) or flask.abort(404)
form = forms.UserSettingsForm(obj=user)
utils.formatCSVField(form.forward_destination)
form.forward_enabled.data = bool(flask.request.form.get('forward_enabled', False))
if form.validate_on_submit():
user.forward_enabled = bool(flask.request.form.get('forward_enabled', False))
if form.forward_enabled and (form.forward_destination.data in ['', None] or type(form.forward_destination.data) is list):
flask.flash('Destination email address is missing', 'error')
return flask.redirect(
flask.url_for('.user_settings', user=user.email))
if not user.forward_enabled and not flask.request.form.get('forward_destination', None):
form.forward_destination.data = ""
flask.url_for('.user_settings', user_email=user_email))
form.forward_destination.data = form.forward_destination.data.replace(" ","").split(",")
form.populate_obj(user)
models.db.session.commit()
@ -109,8 +107,9 @@ def user_settings(user_email):
return flask.redirect(
flask.url_for('.user_list', domain_name=user.domain.name))
elif form.is_submitted() and not form.validate():
flask.flash('Error validating the form', 'error')
return flask.redirect(
flask.url_for('.user_settings', user=user.email))
flask.url_for('.user_settings', user_email=user_email))
return flask.render_template('user/settings.html', form=form, user=user)
def _process_password_change(form, user_email):

View File

@ -532,6 +532,7 @@ def isBadOrPwned(form):
def formatCSVField(field):
if not field.data:
field.data = ''
return
if isinstance(field.data,str):
data = field.data.replace(" ","").split(",")