|
|
|
@ -44,10 +44,9 @@ def deferred_unique_email_validator(node, kw):
@@ -44,10 +44,9 @@ def deferred_unique_email_validator(node, kw):
|
|
|
|
|
email_validator(node, value) # raises exception on invalid address |
|
|
|
|
request = kw.get('request') |
|
|
|
|
user = request.dbsession.query(User).filter_by(email=value).first() |
|
|
|
|
if user not in (request.user, request.context.model): |
|
|
|
|
if user not in (None, request.context.model): |
|
|
|
|
# allow existing email addresses if |
|
|
|
|
# it belongs to the current logged in user or |
|
|
|
|
# an administrator edits a user |
|
|
|
|
# it belongs to the user that is currently edited |
|
|
|
|
raise colander.Invalid(node, 'Email address in use') |
|
|
|
|
return validate_unique_email |
|
|
|
|
|
|
|
|
|