From 508f4d1b526a627571e1a72358e41ad3e4e62ae7 Mon Sep 17 00:00:00 2001 From: Eskil Heyn Olsen Date: Sat, 12 Jan 2013 15:57:52 -0800 Subject: [PATCH] Fix change password form --- flask_security/forms.py | 7 ++++--- flask_security/templates/security/_menu.html | 3 --- flask_security/templates/security/change_password.html | 3 ++- tests/configured_tests.py | 3 ++- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/flask_security/forms.py b/flask_security/forms.py index 4b2808b..48f7b82 100644 --- a/flask_security/forms.py +++ b/flask_security/forms.py @@ -200,8 +200,8 @@ class ResetPasswordForm(Form, NewPasswordFormMixin, PasswordConfirmFormMixin): submit = SubmitField("Reset Password") -class ChangePasswordForm(Form, PasswordFormMixin): - """The default Change password form""" +class ChangePasswordForm(Form, NextFormMixin, PasswordFormMixin): + """The default change password form""" new_password = PasswordField("New Password", validators=[password_required, @@ -213,7 +213,8 @@ class ChangePasswordForm(Form, PasswordFormMixin): submit = SubmitField("Change Password") def validate(self): - super(ChangePasswordForm, self).validate() + if not super(ChangePasswordForm, self).validate(): + return False if self.password.data.strip() == '': self.password.errors.append('Password not provided') diff --git a/flask_security/templates/security/_menu.html b/flask_security/templates/security/_menu.html index 272cd22..5291f80 100644 --- a/flask_security/templates/security/_menu.html +++ b/flask_security/templates/security/_menu.html @@ -5,9 +5,6 @@ {% if security.registerable %}
  • Register
  • {% endif %} - {% if security.changeable %} -
  • Change password
  • - {% endif %} {% if security.recoverable %}
  • Forgot password
  • {% endif %} diff --git a/flask_security/templates/security/change_password.html b/flask_security/templates/security/change_password.html index 5b656bf..02701c4 100644 --- a/flask_security/templates/security/change_password.html +++ b/flask_security/templates/security/change_password.html @@ -6,6 +6,7 @@ {{ render_field_with_errors(change_password_form.password) }} {{ render_field_with_errors(change_password_form.new_password) }} {{ render_field_with_errors(change_password_form.new_password_confirm) }} + {{ render_field(change_password_form.next) }} {{ render_field(change_password_form.submit) }} -{% include "security/_menu.html" %} + diff --git a/tests/configured_tests.py b/tests/configured_tests.py index 9d874b9..c01e3dd 100644 --- a/tests/configured_tests.py +++ b/tests/configured_tests.py @@ -337,7 +337,7 @@ class ChangePasswordTest(SecurityTest): 'new_password': 'newpassword', 'new_password_confirm': 'newpassword' }, follow_redirects=True) - print r + self.assertNotIn('You successfully changed your password', r.data) self.assertIn('Invalid password', r.data) def test_change_password_mismatch(self): @@ -347,6 +347,7 @@ class ChangePasswordTest(SecurityTest): 'new_password': 'newpassword', 'new_password_confirm': 'notnewpassword' }, follow_redirects=True) + self.assertNotIn('You successfully changed your password', r.data) self.assertIn('Passwords do not match', r.data) def test_change_password_success(self):