Changeset - c9fa3f53143b
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 15 years ago 2010-11-23 14:58:29
marcin@python-works.com
added validation of username alphanumeric+dash only
2 files changed with 12 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/forms.py
Show inline comments
 
@@ -32,12 +32,13 @@ from rhodecode.model.repo import RepoMod
 
from rhodecode.model.db import User
 
from webhelpers.pylonslib.secure_form import authentication_token
 
from rhodecode import BACKENDS
 
import formencode
 
import logging
 
import os
 
import re
 
import rhodecode.lib.helpers as h
 

	
 
log = logging.getLogger(__name__)
 

	
 
#this is needed to translate the messages using _() in validators
 
class State_obj(object):
 
@@ -68,13 +69,22 @@ def ValidUsername(edit, old_data):
 

	
 
            if old_un != value or not edit:
 
                if UserModel().get_by_username(value, cache=False,
 
                                               case_insensitive=True):
 
                    raise formencode.Invalid(_('This username already exists') ,
 
                                             value, state)
 

	
 
            
 
            
 
            if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-]+$', value) is None:
 
                raise formencode.Invalid(_('Username may only contain '
 
                                      'alphanumeric characters '
 
                                      'or dashes and cannot begin with a dash'),
 
                                      value, state)
 
            
 
            
 
            
 
    return _ValidUsername
 

	
 
class ValidPassword(formencode.validators.FancyValidator):
 

	
 
    def to_python(self, value, state):
 

	
rhodecode/public/css/style.css
Show inline comments
 
@@ -2300,12 +2300,13 @@ padding:0 0 10px;
 
#login div.form div.fields div.field span.error-message,#register div.form div.fields div.field span.error-message {
 
height:1%;
 
display:block;
 
color:red;
 
margin:8px 0 0;
 
padding:0;
 
width: 320px;
 
}
 
 
#login div.form div.fields div.field div.label label,#register div.form div.fields div.field div.label label {
 
color:#000;
 
font-weight:700;
 
}
0 comments (0 inline, 0 general)