##// END OF EJS Templates
implements #237 added password confirmation for my account and admin edit user.
marcink -
r1597:019026a8 beta
parent child Browse files
Show More
@@ -186,7 +186,8 b' class ValidPasswordsMatch(formencode.val'
186 186
187 187 def validate_python(self, value, state):
188 188
189 if value['password'] != value['password_confirmation']:
189 pass_val = value.get('password') or value.get('new_password')
190 if pass_val != value['password_confirmation']:
190 191 e_dict = {'password_confirmation':
191 192 _('Passwords do not match')}
192 193 raise formencode.Invalid('', value, state, error_dict=e_dict)
@@ -497,8 +498,6 b' class LoginForm(formencode.Schema):'
497 498 'tooShort':_('Enter %(min)i characters or more')}
498 499 )
499 500
500
501 #chained validators have access to all data
502 501 chained_validators = [ValidAuth]
503 502
504 503 def UserForm(edit=False, old_data={}):
@@ -509,15 +508,18 b' def UserForm(edit=False, old_data={}):'
509 508 ValidUsername(edit, old_data))
510 509 if edit:
511 510 new_password = All(UnicodeString(strip=True, min=6, not_empty=False))
511 password_confirmation = All(UnicodeString(strip=True, min=6, not_empty=False))
512 512 admin = StringBoolean(if_missing=False)
513 513 else:
514 514 password = All(UnicodeString(strip=True, min=6, not_empty=True))
515 password_confirmation = All(UnicodeString(strip=True, min=6, not_empty=False))
516
515 517 active = StringBoolean(if_missing=False)
516 518 name = UnicodeString(strip=True, min=1, not_empty=True)
517 519 lastname = UnicodeString(strip=True, min=1, not_empty=True)
518 520 email = All(Email(not_empty=True), UniqSystemEmail(old_data))
519 521
520 chained_validators = [ValidPassword]
522 chained_validators = [ValidPasswordsMatch, ValidPassword]
521 523
522 524 return _UserForm
523 525
@@ -47,6 +47,15 b''
47 47
48 48 <div class="field">
49 49 <div class="label">
50 <label for="password_confirmation">${_('Password confirmation')}:</label>
51 </div>
52 <div class="input">
53 ${h.password('password_confirmation',class_="small",autocomplete="off")}
54 </div>
55 </div>
56
57 <div class="field">
58 <div class="label">
50 59 <label for="name">${_('First Name')}:</label>
51 60 </div>
52 61 <div class="input">
@@ -71,6 +71,15 b''
71 71
72 72 <div class="field">
73 73 <div class="label">
74 <label for="password_confirmation">${_('New password confirmation')}:</label>
75 </div>
76 <div class="input">
77 ${h.password('password_confirmation',class_="medium",autocomplete="off")}
78 </div>
79 </div>
80
81 <div class="field">
82 <div class="label">
74 83 <label for="name">${_('First Name')}:</label>
75 84 </div>
76 85 <div class="input">
@@ -60,6 +60,15 b''
60 60
61 61 <div class="field">
62 62 <div class="label">
63 <label for="password_confirmation">${_('New password confirmation')}:</label>
64 </div>
65 <div class="input">
66 ${h.password('password_confirmation',class_="medium",autocomplete="off")}
67 </div>
68 </div>
69
70 <div class="field">
71 <div class="label">
63 72 <label for="name">${_('First Name')}:</label>
64 73 </div>
65 74 <div class="input">
@@ -154,10 +163,12 b''
154 163 </tr>
155 164 %endfor
156 165 %else:
166 <div style="padding:5px 0px 10px 0px;">
157 167 ${_('No repositories yet')}
158 168 %if h.HasPermissionAny('hg.admin','hg.create.repository')():
159 ${h.link_to(_('create one now'),h.url('admin_settings_create_repository'))}
169 ${h.link_to(_('create one now'),h.url('admin_settings_create_repository'),class_="ui-button-small")}
160 170 %endif
171 </div>
161 172 %endif
162 173 </tbody>
163 174 </table>
@@ -137,6 +137,7 b' class TestAdminSettingsController(TestCo'
137 137 params=dict(_method='put',
138 138 username='test_admin',
139 139 new_password=new_password,
140 password_confirmation = new_password,
140 141 password='',
141 142 name=new_name,
142 143 lastname=new_lastname,
@@ -160,6 +161,7 b' class TestAdminSettingsController(TestCo'
160 161 _method='put',
161 162 username='test_admin',
162 163 new_password=old_password,
164 password_confirmation = old_password,
163 165 password='',
164 166 name=old_name,
165 167 lastname=old_lastname,
@@ -186,6 +188,7 b' class TestAdminSettingsController(TestCo'
186 188 _method='put',
187 189 username='test_admin',
188 190 new_password='test12',
191 password_confirmation = 'test122',
189 192 name='NewName',
190 193 lastname='NewLastname',
191 194 email=new_email,))
@@ -201,6 +204,7 b' class TestAdminSettingsController(TestCo'
201 204 _method='put',
202 205 username='test_admin',
203 206 new_password='test12',
207 password_confirmation = 'test122',
204 208 name='NewName',
205 209 lastname='NewLastname',
206 210 email=new_email,))
@@ -16,12 +16,14 b' class TestAdminUsersController(TestContr'
16 16 self.log_user()
17 17 username = 'newtestuser'
18 18 password = 'test12'
19 password_confirmation = password
19 20 name = 'name'
20 21 lastname = 'lastname'
21 22 email = 'mail@mail.com'
22 23
23 24 response = self.app.post(url('users'), {'username':username,
24 25 'password':password,
26 'password_confirmation':password_confirmation,
25 27 'name':name,
26 28 'active':True,
27 29 'lastname':lastname,
@@ -90,6 +92,7 b' class TestAdminUsersController(TestContr'
90 92
91 93 response = self.app.post(url('users'), {'username':username,
92 94 'password':password,
95 'password_confirmation':password,
93 96 'name':name,
94 97 'active':True,
95 98 'lastname':lastname,
General Comments 0
You need to be logged in to leave comments. Login now