Browse Source

bugfix in deferred_unique_email_validator

php2python
Holger Frey 7 years ago
parent
commit
e82416882b
  1. 5
      ordr2/resources/account.py
  2. 5
      ordr2/schemas/helpers.py

5
ordr2/resources/account.py

@ -5,6 +5,11 @@ from .base import BaseResource @@ -5,6 +5,11 @@ from .base import BaseResource
class Account(BaseResource):
def __init__(self, name, parent):
super().__init__(name, parent)
self.model = self.request.user
def __acl__(self):
return [
(Allow, Everyone, 'login'),

5
ordr2/schemas/helpers.py

@ -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