aboutsummaryrefslogtreecommitdiff
path: root/rhodecode/model/forms.py
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2010-11-23 14:58:29 +0100
committerMarcin Kuzminski <marcin@python-works.com>2010-11-23 14:58:29 +0100
commita459eb58c5c32d592237f33c01e9a88f12c06dc3 (patch)
treefbd45b6ae0a8767ba9d2004f59398591c9070a8a /rhodecode/model/forms.py
parent2f4521579159c1aff66dadd014afa407ee16d1fd (diff)
added validation of username alphanumeric+dash only
--HG-- branch : beta
Diffstat (limited to 'rhodecode/model/forms.py')
-rw-r--r--rhodecode/model/forms.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py
index e9660f91..1b418a7a 100644
--- a/rhodecode/model/forms.py
+++ b/rhodecode/model/forms.py
@@ -35,6 +35,7 @@ from rhodecode import BACKENDS
import formencode
import logging
import os
+import re
import rhodecode.lib.helpers as h
log = logging.getLogger(__name__)
@@ -71,7 +72,16 @@ def ValidUsername(edit, old_data):
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):