Show More
@@ -64,6 +64,7 b' class ChangePasswordSchema(colander.Sche' | |||||
64 |
|
64 | |||
65 | @colander.deferred |
|
65 | @colander.deferred | |
66 | def deferred_username_validator(node, kw): |
|
66 | def deferred_username_validator(node, kw): | |
|
67 | old_username = kw.get('username') | |||
67 |
|
68 | |||
68 | def name_validator(node, value): |
|
69 | def name_validator(node, value): | |
69 | msg = _( |
|
70 | msg = _( | |
@@ -74,6 +75,11 b' def deferred_username_validator(node, kw' | |||||
74 | if not re.match(r'^[\w]{1}[\w\-\.]{0,254}$', value): |
|
75 | if not re.match(r'^[\w]{1}[\w\-\.]{0,254}$', value): | |
75 | raise colander.Invalid(node, msg) |
|
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 | return name_validator |
|
83 | return name_validator | |
78 |
|
84 | |||
79 |
|
85 |
General Comments 0
You need to be logged in to leave comments.
Login now