diff --git a/app/blueprints/users/account.py b/app/blueprints/users/account.py index c82a5924..9741b579 100644 --- a/app/blueprints/users/account.py +++ b/app/blueprints/users/account.py @@ -206,13 +206,13 @@ def forgot_password(): class SetPasswordForm(FlaskForm): email = StringField("Email", [Optional(), Email()]) password = PasswordField("New password", [InputRequired(), Length(8, 100)]) - password2 = PasswordField("Verify password", [InputRequired(), Length(8, 100)]) + password2 = PasswordField("Verify password", [InputRequired(), Length(8, 100), validators.EqualTo('password', message='Passwords must match')]) submit = SubmitField("Save") class ChangePasswordForm(FlaskForm): old_password = PasswordField("Old password", [InputRequired(), Length(8, 100)]) password = PasswordField("New password", [InputRequired(), Length(8, 100)]) - password2 = PasswordField("Verify password", [InputRequired(), Length(8, 100)]) + password2 = PasswordField("Verify password", [InputRequired(), Length(8, 100), validators.EqualTo('password', message='Passwords must match')]) submit = SubmitField("Save") @@ -252,9 +252,6 @@ def handle_set_password(form): def change_password(): form = ChangePasswordForm(request.form) - if current_user.email is None: - form.email.validators = [InputRequired(), Email()] - if form.validate_on_submit(): if check_password_hash(current_user.password, form.old_password.data): ret = handle_set_password(form) diff --git a/app/templates/macros/forms.html b/app/templates/macros/forms.html index 9aaa55e6..a58a2a32 100644 --- a/app/templates/macros/forms.html +++ b/app/templates/macros/forms.html @@ -1,20 +1,22 @@ +{% macro render_errors(field) %} + {% for e in field.errors %} +
{{ e }}
+ {% endfor %} +{% endmacro %} + {% macro render_field(field, label=None, label_visible=true, right_url=None, right_label=None, fieldclass=None) -%} -{{ e }}
- {% endfor %} - {% endif %} + {{ render_errors(field) }}{{ e }}
- {% endfor %} - {% endif %} + {{ render_errors(field) }}{{ e }}
- {% endfor %} - {% endif %} + {{ render_errors(field) }}{{ e }}
- {% endfor %} - {% endif %} + {{ render_errors(field) }}{{ e }}
- {% endfor %} - {% endif %} + {{ render_errors(field) }}