mirror of
https://github.com/wassname/flask-security.git
synced 2026-08-11 11:18:40 +08:00
Show an error if a user tries to change their password and its the same as before. Fixes #160
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user