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