Changeset - 02bdf2f296ff
[Not reviewed]
beta
0 4 0
Marcin Kuzminski - 15 years ago 2010-11-18 23:07:04
marcin@python-works.com
fixes #69 password confirmation for register dialog.
Fixes appcrash when using some special characters in register field
fixes app crash when no email config is enabled
4 files changed with 67 insertions and 18 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/celerylib/tasks.py
Show inline comments
 
@@ -255,7 +255,7 @@ def send_email(recipients, subject, body
 
        recipients = [email_config.get('email_to')]
 

	
 
    def str2bool(v):
 
        return v.lower() in ["yes", "true", "t", "1"]
 
        return v.lower() in ["yes", "true", "t", "1"] if v else None
 

	
 
    mail_from = email_config.get('app_email_from')
 
    user = email_config.get('smtp_username')
rhodecode/model/forms.py
Show inline comments
 
@@ -76,8 +76,34 @@ def ValidUsername(edit, old_data):
 
class ValidPassword(formencode.validators.FancyValidator):
 

	
 
    def to_python(self, value, state):
 

	
 
        if value:
 
            return get_crypt_password(value)
 

	
 
            if value.get('password'):
 
                try:
 
                    value['password'] = get_crypt_password(value['password'])
 
                except UnicodeEncodeError:
 
                    e_dict = {'password':_('Invalid characters in password')}
 
                    raise formencode.Invalid('', value, state, error_dict=e_dict)
 

	
 
            if value.get('password_confirmation'):
 
                try:
 
                    value['password_confirmation'] = \
 
                        get_crypt_password(value['password_confirmation'])
 
                except UnicodeEncodeError:
 
                    e_dict = {'password_confirmation':_('Invalid characters in password')}
 
                    raise formencode.Invalid('', value, state, error_dict=e_dict)
 

	
 
            return value
 

	
 
class ValidPasswordsMatch(formencode.validators.FancyValidator):
 

	
 
    def validate_python(self, value, state):
 

	
 
        if value['password'] != value['password_confirmation']:
 
            e_dict = {'password_confirmation':
 
                   _('Password do not match')}
 
            raise formencode.Invalid('', value, state, error_dict=e_dict)
 

	
 
class ValidAuth(formencode.validators.FancyValidator):
 
    messages = {
 
@@ -281,18 +307,34 @@ def UserForm(edit=False, old_data={}):
 
        filter_extra_fields = True
 
        username = All(UnicodeString(strip=True, min=1, not_empty=True), ValidUsername(edit, old_data))
 
        if edit:
 
            new_password = All(UnicodeString(strip=True, min=6, not_empty=False), ValidPassword)
 
            new_password = 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), ValidPassword)
 
            password = All(UnicodeString(strip=True, min=6, not_empty=True))
 
        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]
 

	
 
    return _UserForm
 

	
 
RegisterForm = UserForm
 
def RegisterForm(edit=False, old_data={}):
 
    class _RegisterForm(formencode.Schema):
 
        allow_extra_fields = True
 
        filter_extra_fields = True
 
        username = All(ValidUsername(edit, old_data), UnicodeString(strip=True, min=1, not_empty=True))
 
        password = All(UnicodeString(strip=True, min=6, not_empty=True))
 
        password_confirmation = All(UnicodeString(strip=True, min=6, not_empty=True))
 
        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 = [ValidPasswordsMatch, ValidPassword]
 

	
 
    return _RegisterForm
 

	
 
def PasswordResetForm():
 
    class _PasswordResetForm(formencode.Schema):
rhodecode/public/css/style.css
Show inline comments
 
@@ -1327,7 +1327,6 @@ padding:0 0 2px;
 
}
 
 
#register div.title {
 
width:420px;
 
clear:both;
 
overflow:hidden;
 
position:relative;
 
@@ -1337,7 +1336,6 @@ padding:0;
 
}
 
 
#register div.inner {
 
width:380px;
 
background:#FFF;
 
border-top:none;
 
border-bottom:none;
 
@@ -1346,7 +1344,7 @@ padding:20px;
 
}
 
 
#register div.form div.fields div.field div.label {
 
width:100px;
 
width:135px;
 
float:left;
 
text-align:right;
 
margin:2px 10px 0 0;
 
@@ -1354,7 +1352,7 @@ padding:5px 0 0 5px;
 
}
 
 
#register div.form div.fields div.field div.input input {
 
width:245px;
 
width:300px;
 
background:#FFF;
 
border-top:1px solid #b3b3b3;
 
border-left:1px solid #b3b3b3;
 
@@ -2235,7 +2233,7 @@ padding:6px;
 
}
 
 
#login,#register {
 
width:420px;
 
width:520px;
 
margin:10% auto 0;
 
padding:0;
 
}
rhodecode/templates/register.html
Show inline comments
 
@@ -15,7 +15,7 @@
 
		<div id="register">
 
			
 
			<div class="title top-left-rounded-corner top-right-rounded-corner">
 
				<h5>${_('Sign Up to rhodecode')}</h5>
 
				<h5>${_('Sign Up to RhodeCode')}</h5>
 
			</div>
 
			<div class="inner">
 
			    ${h.form(url('register'))}
 
@@ -27,25 +27,34 @@
 
			                    <label for="username">${_('Username')}:</label>
 
			                </div>
 
			                <div class="input">
 
			                    ${h.text('username')}
 
			                    ${h.text('username',class_="medium")}
 
			                </div>
 
			             </div>
 
			            
 
			             <div class="field">
 
			                <div class="label">
 
			                    <label for="password">${_('New Password')}:</label>
 
			                    <label for="password">${_('Password')}:</label>
 
			                </div>
 
			                <div class="input">
 
			                    ${h.password('password')}
 
			                    ${h.password('password',class_="medium")}
 
			                </div>
 
			             </div>
 
			            
 
                         
 
                         <div class="field">
 
                            <div class="label">
 
                                <label for="password">${_('Re-enter password')}:</label>
 
                            </div>
 
                            <div class="input">
 
                                ${h.password('password_confirmation',class_="medium")}
 
                            </div>
 
                         </div>
 
                         			            
 
			             <div class="field">
 
			                <div class="label">
 
			                    <label for="name">${_('First Name')}:</label>
 
			                </div>
 
			                <div class="input">
 
			                    ${h.text('name')}
 
			                    ${h.text('name',class_="medium")}
 
			                </div>
 
			             </div>
 
			            
 
@@ -54,7 +63,7 @@
 
			                    <label for="lastname">${_('Last Name')}:</label>
 
			                </div>
 
			                <div class="input">
 
			                    ${h.text('lastname')}
 
			                    ${h.text('lastname',class_="medium")}
 
			                </div>
 
			             </div>
 
			            
 
@@ -63,7 +72,7 @@
 
			                    <label for="email">${_('Email')}:</label>
 
			                </div>
 
			                <div class="input">
 
			                    ${h.text('email')}
 
			                    ${h.text('email',class_="medium")}
 
			                </div>
 
			             </div>
 
			                        
0 comments (0 inline, 0 general)