##// END OF EJS Templates
feat(forms): user profile form would detect nicely duplicates and show a form error.
super-admin -
r5353:7a7f1159 default
parent child Browse files
Show More
@@ -64,6 +64,7 b' class ChangePasswordSchema(colander.Sche'
64 64
65 65 @colander.deferred
66 66 def deferred_username_validator(node, kw):
67 old_username = kw.get('username')
67 68
68 69 def name_validator(node, value):
69 70 msg = _(
@@ -74,6 +75,11 b' def deferred_username_validator(node, kw'
74 75 if not re.match(r'^[\w]{1}[\w\-\.]{0,254}$', value):
75 76 raise colander.Invalid(node, msg)
76 77
78 if value != old_username:
79 existing_user = User.get_by_username(value, case_insensitive=True)
80 if existing_user:
81 raise colander.Invalid(node, 'Username is already taken')
82
77 83 return name_validator
78 84
79 85
General Comments 0
You need to be logged in to leave comments. Login now