Fix change password form

This commit is contained in:
Eskil Heyn Olsen
2013-01-12 15:57:52 -08:00
parent 050ccb847a
commit 508f4d1b52
4 changed files with 8 additions and 8 deletions
+4 -3
View File
@@ -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')
@@ -5,9 +5,6 @@
{% if security.registerable %}
<li><a href="{{ url_for_security('register') }}">Register</a><br/></li>
{% endif %}
{% if security.changeable %}
<li><a href="{{ url_for_security('change_password') }}">Change password</a></li>
{% endif %}
{% if security.recoverable %}
<li><a href="{{ url_for_security('forgot_password') }}">Forgot password</a><br/></li>
{% endif %}
@@ -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) }}
</form>
{% include "security/_menu.html" %}
+2 -1
View File
@@ -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):