diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py --- a/rhodecode/model/forms.py +++ b/rhodecode/model/forms.py @@ -185,8 +185,9 @@ class ValidPassword(formencode.validator class ValidPasswordsMatch(formencode.validators.FancyValidator): def validate_python(self, value, state): - - if value['password'] != value['password_confirmation']: + + pass_val = value.get('password') or value.get('new_password') + if pass_val != value['password_confirmation']: e_dict = {'password_confirmation': _('Passwords do not match')} raise formencode.Invalid('', value, state, error_dict=e_dict) @@ -497,8 +498,6 @@ class LoginForm(formencode.Schema): 'tooShort':_('Enter %(min)i characters or more')} ) - - #chained validators have access to all data chained_validators = [ValidAuth] def UserForm(edit=False, old_data={}): @@ -509,15 +508,18 @@ def UserForm(edit=False, old_data={}): ValidUsername(edit, old_data)) if edit: new_password = All(UnicodeString(strip=True, min=6, not_empty=False)) + password_confirmation = All(UnicodeString(strip=True, min=6, not_empty=False)) admin = StringBoolean(if_missing=False) else: password = All(UnicodeString(strip=True, min=6, not_empty=True)) + password_confirmation = All(UnicodeString(strip=True, min=6, not_empty=False)) + active = StringBoolean(if_missing=False) name = UnicodeString(strip=True, min=1, not_empty=True) lastname = UnicodeString(strip=True, min=1, not_empty=True) email = All(Email(not_empty=True), UniqSystemEmail(old_data)) - chained_validators = [ValidPassword] + chained_validators = [ValidPasswordsMatch, ValidPassword] return _UserForm diff --git a/rhodecode/templates/admin/users/user_add.html b/rhodecode/templates/admin/users/user_add.html --- a/rhodecode/templates/admin/users/user_add.html +++ b/rhodecode/templates/admin/users/user_add.html @@ -44,7 +44,16 @@ ${h.password('password',class_='small')} - + +
+
+ +
+
+ ${h.password('password_confirmation',class_="small",autocomplete="off")} +
+
+
diff --git a/rhodecode/templates/admin/users/user_edit.html b/rhodecode/templates/admin/users/user_edit.html --- a/rhodecode/templates/admin/users/user_edit.html +++ b/rhodecode/templates/admin/users/user_edit.html @@ -68,7 +68,16 @@ ${h.password('new_password',class_='medium',autocomplete="off")}
- + +
+
+ +
+
+ ${h.password('password_confirmation',class_="medium",autocomplete="off")} +
+
+
diff --git a/rhodecode/templates/admin/users/user_edit_my_account.html b/rhodecode/templates/admin/users/user_edit_my_account.html --- a/rhodecode/templates/admin/users/user_edit_my_account.html +++ b/rhodecode/templates/admin/users/user_edit_my_account.html @@ -57,7 +57,16 @@ ${h.password('new_password',class_="medium",autocomplete="off")}
- + +
+
+ +
+
+ ${h.password('password_confirmation',class_="medium",autocomplete="off")} +
+
+
@@ -154,10 +163,12 @@ %endfor %else: +
${_('No repositories yet')} %if h.HasPermissionAny('hg.admin','hg.create.repository')(): - ${h.link_to(_('create one now'),h.url('admin_settings_create_repository'))} + ${h.link_to(_('create one now'),h.url('admin_settings_create_repository'),class_="ui-button-small")} %endif +
%endif diff --git a/rhodecode/tests/functional/test_admin_settings.py b/rhodecode/tests/functional/test_admin_settings.py --- a/rhodecode/tests/functional/test_admin_settings.py +++ b/rhodecode/tests/functional/test_admin_settings.py @@ -137,6 +137,7 @@ class TestAdminSettingsController(TestCo params=dict(_method='put', username='test_admin', new_password=new_password, + password_confirmation = new_password, password='', name=new_name, lastname=new_lastname, @@ -160,6 +161,7 @@ class TestAdminSettingsController(TestCo _method='put', username='test_admin', new_password=old_password, + password_confirmation = old_password, password='', name=old_name, lastname=old_lastname, @@ -186,6 +188,7 @@ class TestAdminSettingsController(TestCo _method='put', username='test_admin', new_password='test12', + password_confirmation = 'test122', name='NewName', lastname='NewLastname', email=new_email,)) @@ -201,6 +204,7 @@ class TestAdminSettingsController(TestCo _method='put', username='test_admin', new_password='test12', + password_confirmation = 'test122', name='NewName', lastname='NewLastname', email=new_email,)) diff --git a/rhodecode/tests/functional/test_admin_users.py b/rhodecode/tests/functional/test_admin_users.py --- a/rhodecode/tests/functional/test_admin_users.py +++ b/rhodecode/tests/functional/test_admin_users.py @@ -16,12 +16,14 @@ class TestAdminUsersController(TestContr self.log_user() username = 'newtestuser' password = 'test12' + password_confirmation = password name = 'name' lastname = 'lastname' email = 'mail@mail.com' response = self.app.post(url('users'), {'username':username, 'password':password, + 'password_confirmation':password_confirmation, 'name':name, 'active':True, 'lastname':lastname, @@ -90,6 +92,7 @@ class TestAdminUsersController(TestContr response = self.app.post(url('users'), {'username':username, 'password':password, + 'password_confirmation':password, 'name':name, 'active':True, 'lastname':lastname,