Mercurial > kallithea
changeset 743:c9fa3f53143b beta
added validation of username alphanumeric+dash only
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 23 Nov 2010 14:58:29 +0100 |
parents | 1377a9d4bdb9 |
children | 3389f272ece1 |
files | rhodecode/model/forms.py rhodecode/public/css/style.css |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/model/forms.py Tue Nov 23 14:15:45 2010 +0100 +++ b/rhodecode/model/forms.py Tue Nov 23 14:58:29 2010 +0100 @@ -35,6 +35,7 @@ import formencode import logging import os +import re import rhodecode.lib.helpers as h log = logging.getLogger(__name__) @@ -71,7 +72,16 @@ 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):
--- a/rhodecode/public/css/style.css Tue Nov 23 14:15:45 2010 +0100 +++ b/rhodecode/public/css/style.css Tue Nov 23 14:58:29 2010 +0100 @@ -2303,6 +2303,7 @@ 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 {