##// END OF EJS Templates
fixes #69 password confirmation for register dialog....
marcink -
r722:02bdf2f2 beta
parent child Browse files
Show More
@@ -255,7 +255,7 b' def send_email(recipients, subject, body'
255 recipients = [email_config.get('email_to')]
255 recipients = [email_config.get('email_to')]
256
256
257 def str2bool(v):
257 def str2bool(v):
258 return v.lower() in ["yes", "true", "t", "1"]
258 return v.lower() in ["yes", "true", "t", "1"] if v else None
259
259
260 mail_from = email_config.get('app_email_from')
260 mail_from = email_config.get('app_email_from')
261 user = email_config.get('smtp_username')
261 user = email_config.get('smtp_username')
@@ -76,8 +76,34 b' def ValidUsername(edit, old_data):'
76 class ValidPassword(formencode.validators.FancyValidator):
76 class ValidPassword(formencode.validators.FancyValidator):
77
77
78 def to_python(self, value, state):
78 def to_python(self, value, state):
79
79 if value:
80 if value:
80 return get_crypt_password(value)
81
82 if value.get('password'):
83 try:
84 value['password'] = get_crypt_password(value['password'])
85 except UnicodeEncodeError:
86 e_dict = {'password':_('Invalid characters in password')}
87 raise formencode.Invalid('', value, state, error_dict=e_dict)
88
89 if value.get('password_confirmation'):
90 try:
91 value['password_confirmation'] = \
92 get_crypt_password(value['password_confirmation'])
93 except UnicodeEncodeError:
94 e_dict = {'password_confirmation':_('Invalid characters in password')}
95 raise formencode.Invalid('', value, state, error_dict=e_dict)
96
97 return value
98
99 class ValidPasswordsMatch(formencode.validators.FancyValidator):
100
101 def validate_python(self, value, state):
102
103 if value['password'] != value['password_confirmation']:
104 e_dict = {'password_confirmation':
105 _('Password do not match')}
106 raise formencode.Invalid('', value, state, error_dict=e_dict)
81
107
82 class ValidAuth(formencode.validators.FancyValidator):
108 class ValidAuth(formencode.validators.FancyValidator):
83 messages = {
109 messages = {
@@ -281,18 +307,34 b' def UserForm(edit=False, old_data={}):'
281 filter_extra_fields = True
307 filter_extra_fields = True
282 username = All(UnicodeString(strip=True, min=1, not_empty=True), ValidUsername(edit, old_data))
308 username = All(UnicodeString(strip=True, min=1, not_empty=True), ValidUsername(edit, old_data))
283 if edit:
309 if edit:
284 new_password = All(UnicodeString(strip=True, min=6, not_empty=False), ValidPassword)
310 new_password = All(UnicodeString(strip=True, min=6, not_empty=False))
285 admin = StringBoolean(if_missing=False)
311 admin = StringBoolean(if_missing=False)
286 else:
312 else:
287 password = All(UnicodeString(strip=True, min=6, not_empty=True), ValidPassword)
313 password = All(UnicodeString(strip=True, min=6, not_empty=True))
288 active = StringBoolean(if_missing=False)
314 active = StringBoolean(if_missing=False)
289 name = UnicodeString(strip=True, min=1, not_empty=True)
315 name = UnicodeString(strip=True, min=1, not_empty=True)
290 lastname = UnicodeString(strip=True, min=1, not_empty=True)
316 lastname = UnicodeString(strip=True, min=1, not_empty=True)
291 email = All(Email(not_empty=True), UniqSystemEmail(old_data))
317 email = All(Email(not_empty=True), UniqSystemEmail(old_data))
292
318
319 chained_validators = [ValidPassword]
320
293 return _UserForm
321 return _UserForm
294
322
295 RegisterForm = UserForm
323 def RegisterForm(edit=False, old_data={}):
324 class _RegisterForm(formencode.Schema):
325 allow_extra_fields = True
326 filter_extra_fields = True
327 username = All(ValidUsername(edit, old_data), UnicodeString(strip=True, min=1, not_empty=True))
328 password = All(UnicodeString(strip=True, min=6, not_empty=True))
329 password_confirmation = All(UnicodeString(strip=True, min=6, not_empty=True))
330 active = StringBoolean(if_missing=False)
331 name = UnicodeString(strip=True, min=1, not_empty=True)
332 lastname = UnicodeString(strip=True, min=1, not_empty=True)
333 email = All(Email(not_empty=True), UniqSystemEmail(old_data))
334
335 chained_validators = [ValidPasswordsMatch, ValidPassword]
336
337 return _RegisterForm
296
338
297 def PasswordResetForm():
339 def PasswordResetForm():
298 class _PasswordResetForm(formencode.Schema):
340 class _PasswordResetForm(formencode.Schema):
@@ -1327,7 +1327,6 b' padding:0 0 2px;'
1327 }
1327 }
1328
1328
1329 #register div.title {
1329 #register div.title {
1330 width:420px;
1331 clear:both;
1330 clear:both;
1332 overflow:hidden;
1331 overflow:hidden;
1333 position:relative;
1332 position:relative;
@@ -1337,7 +1336,6 b' padding:0;'
1337 }
1336 }
1338
1337
1339 #register div.inner {
1338 #register div.inner {
1340 width:380px;
1341 background:#FFF;
1339 background:#FFF;
1342 border-top:none;
1340 border-top:none;
1343 border-bottom:none;
1341 border-bottom:none;
@@ -1346,7 +1344,7 b' padding:20px;'
1346 }
1344 }
1347
1345
1348 #register div.form div.fields div.field div.label {
1346 #register div.form div.fields div.field div.label {
1349 width:100px;
1347 width:135px;
1350 float:left;
1348 float:left;
1351 text-align:right;
1349 text-align:right;
1352 margin:2px 10px 0 0;
1350 margin:2px 10px 0 0;
@@ -1354,7 +1352,7 b' padding:5px 0 0 5px;'
1354 }
1352 }
1355
1353
1356 #register div.form div.fields div.field div.input input {
1354 #register div.form div.fields div.field div.input input {
1357 width:245px;
1355 width:300px;
1358 background:#FFF;
1356 background:#FFF;
1359 border-top:1px solid #b3b3b3;
1357 border-top:1px solid #b3b3b3;
1360 border-left:1px solid #b3b3b3;
1358 border-left:1px solid #b3b3b3;
@@ -2235,7 +2233,7 b' padding:6px;'
2235 }
2233 }
2236
2234
2237 #login,#register {
2235 #login,#register {
2238 width:420px;
2236 width:520px;
2239 margin:10% auto 0;
2237 margin:10% auto 0;
2240 padding:0;
2238 padding:0;
2241 }
2239 }
@@ -15,7 +15,7 b''
15 <div id="register">
15 <div id="register">
16
16
17 <div class="title top-left-rounded-corner top-right-rounded-corner">
17 <div class="title top-left-rounded-corner top-right-rounded-corner">
18 <h5>${_('Sign Up to rhodecode')}</h5>
18 <h5>${_('Sign Up to RhodeCode')}</h5>
19 </div>
19 </div>
20 <div class="inner">
20 <div class="inner">
21 ${h.form(url('register'))}
21 ${h.form(url('register'))}
@@ -27,16 +27,25 b''
27 <label for="username">${_('Username')}:</label>
27 <label for="username">${_('Username')}:</label>
28 </div>
28 </div>
29 <div class="input">
29 <div class="input">
30 ${h.text('username')}
30 ${h.text('username',class_="medium")}
31 </div>
31 </div>
32 </div>
32 </div>
33
33
34 <div class="field">
34 <div class="field">
35 <div class="label">
35 <div class="label">
36 <label for="password">${_('New Password')}:</label>
36 <label for="password">${_('Password')}:</label>
37 </div>
37 </div>
38 <div class="input">
38 <div class="input">
39 ${h.password('password')}
39 ${h.password('password',class_="medium")}
40 </div>
41 </div>
42
43 <div class="field">
44 <div class="label">
45 <label for="password">${_('Re-enter password')}:</label>
46 </div>
47 <div class="input">
48 ${h.password('password_confirmation',class_="medium")}
40 </div>
49 </div>
41 </div>
50 </div>
42
51
@@ -45,7 +54,7 b''
45 <label for="name">${_('First Name')}:</label>
54 <label for="name">${_('First Name')}:</label>
46 </div>
55 </div>
47 <div class="input">
56 <div class="input">
48 ${h.text('name')}
57 ${h.text('name',class_="medium")}
49 </div>
58 </div>
50 </div>
59 </div>
51
60
@@ -54,7 +63,7 b''
54 <label for="lastname">${_('Last Name')}:</label>
63 <label for="lastname">${_('Last Name')}:</label>
55 </div>
64 </div>
56 <div class="input">
65 <div class="input">
57 ${h.text('lastname')}
66 ${h.text('lastname',class_="medium")}
58 </div>
67 </div>
59 </div>
68 </div>
60
69
@@ -63,7 +72,7 b''
63 <label for="email">${_('Email')}:</label>
72 <label for="email">${_('Email')}:</label>
64 </div>
73 </div>
65 <div class="input">
74 <div class="input">
66 ${h.text('email')}
75 ${h.text('email',class_="medium")}
67 </div>
76 </div>
68 </div>
77 </div>
69
78
General Comments 0
You need to be logged in to leave comments. Login now