Public bug reported:

When creating a new user via the REST API, if the email address exists,
it reports "Address already exists", but it creates the user anyway.

After a bit of deep cave diving into the code I suspect it’s this in
model/usermanager.py

This function appears to create a user before it checks to see if the
address exists, with the result that multiple users are created when the
address already exists.

@implementer(IUserManager)
class UserManager:
   """See `IUserManager`."""

   def create_user(self, email=None, display_name=None):
       """See `IUserManager`."""
       user = User(display_name, Preferences())
       if email:
           address = self.create_address(email, display_name)
           user.link(address)
       return user


this seems to fix the problem - but please don’t trust my solution - needs 
verification.

@implementer(IUserManager)
class UserManager:
   """See `IUserManager`."""

   def create_user(self, email=None, display_name=None):
       """See `IUserManager`."""
       if email:
           address = self.create_address(email, display_name)
       user = User(display_name, Preferences())
       if email:
           user.link(address)
       return user

** Affects: mailman
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Mailman
Coders, which is subscribed to GNU Mailman.
https://bugs.launchpad.net/bugs/1418280

Title:
  "Address already exists" when creating a new user, but user is created
  anyway

To manage notifications about this bug go to:
https://bugs.launchpad.net/mailman/+bug/1418280/+subscriptions
_______________________________________________
Mailman-coders mailing list
Mailman-coders@python.org
https://mail.python.org/mailman/listinfo/mailman-coders

Reply via email to