Mercurial > kallithea
comparison rhodecode/model/forms.py @ 1757:2aa7f454204e beta
fixes #298, ldap email addresses created by rhodecode automatically during first login didn't get converted to lower case, which lead to lookup failures and than wrong checks for uniqueness. Fixed that by putting a setter on db model column that will enforce converting to lowercase.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 06 Dec 2011 01:18:27 +0200 |
parents | 8ecc6b8229a5 |
children | 9dda1146327c |
comparison
equal
deleted
inserted
replaced
1756:60a00fd76d58 | 1757:2aa7f454204e |
---|---|
394 return value | 394 return value |
395 | 395 |
396 class ValidSettings(formencode.validators.FancyValidator): | 396 class ValidSettings(formencode.validators.FancyValidator): |
397 | 397 |
398 def to_python(self, value, state): | 398 def to_python(self, value, state): |
399 #settings form can't edit user | 399 # settings form can't edit user |
400 if value.has_key('user'): | 400 if value.has_key('user'): |
401 del['value']['user'] | 401 del['value']['user'] |
402 | 402 |
403 return value | 403 return value |
404 | 404 |
414 def UniqSystemEmail(old_data): | 414 def UniqSystemEmail(old_data): |
415 class _UniqSystemEmail(formencode.validators.FancyValidator): | 415 class _UniqSystemEmail(formencode.validators.FancyValidator): |
416 def to_python(self, value, state): | 416 def to_python(self, value, state): |
417 value = value.lower() | 417 value = value.lower() |
418 if old_data.get('email') != value: | 418 if old_data.get('email') != value: |
419 user = User.query().filter(User.email == value).scalar() | 419 user = User.get_by_email(value, case_insensitive=True) |
420 if user: | 420 if user: |
421 raise formencode.Invalid( | 421 raise formencode.Invalid( |
422 _("This e-mail address is already taken"), | 422 _("This e-mail address is already taken"), |
423 value, state) | 423 value, state) |
424 return value | 424 return value |
426 return _UniqSystemEmail | 426 return _UniqSystemEmail |
427 | 427 |
428 class ValidSystemEmail(formencode.validators.FancyValidator): | 428 class ValidSystemEmail(formencode.validators.FancyValidator): |
429 def to_python(self, value, state): | 429 def to_python(self, value, state): |
430 value = value.lower() | 430 value = value.lower() |
431 user = User.query().filter(User.email == value).scalar() | 431 user = User.get_by_email(value, case_insensitive=True) |
432 if user is None: | 432 if user is None: |
433 raise formencode.Invalid(_("This e-mail address doesn't exist.") , | 433 raise formencode.Invalid(_("This e-mail address doesn't exist.") , |
434 value, state) | 434 value, state) |
435 | 435 |
436 return value | 436 return value |