Show an error if a user tries to change their password and its the same as before. Fixes #160

This commit is contained in:
Matt Wright
2013-10-16 11:15:17 -04:00
parent b1ac2598c0
commit 9999325ffb
3 changed files with 15 additions and 1 deletions
+4 -1
View File
@@ -22,7 +22,7 @@ from flask_login import current_user
from werkzeug.local import LocalProxy
from .confirmable import requires_confirmation
from .utils import verify_and_update_password, get_message
from .utils import verify_and_update_password, get_message, encrypt_password
# Convenient reference
_datastore = LocalProxy(lambda: current_app.extensions['security'].datastore)
@@ -275,4 +275,7 @@ class ChangePasswordForm(Form, PasswordFormMixin):
if not verify_and_update_password(self.password.data, current_user):
self.password.errors.append(get_message('INVALID_PASSWORD')[0])
return False
if self.password.data.strip() == self.new_password.data.strip():
self.password.errors.append(get_message('PASSWORD_IS_THE_SAME')[0])
return False
return True