Skip to content


Subversion checkout URL

You can clone with
Download ZIP


fix: fail silently if ACCOUNT_EMAIL_UNIQUE is True but adding a same email #62

wants to merge 1 commit into from

2 participants


Currently if


and a new account with same email is to be created,
it just fails silently.

We should throw the exception to let further handling.

@brosner brosner closed this pull request from a commit
@brosner brosner Allow IntegrityError to propagate with duplicate email
Fixes #62. When ACCOUNT_EMAIL_UNIQUE is True we should fail loudly when an
attempt to insert a duplicate occurs. Let the callers handle the failure.
@brosner brosner closed this in 0007ea4

I would have merged this pull request, but it no longer merged cleanly so I did it myself.

This is a good catch. I believe the code was left over from the very early days before uniqueness was supported. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 12 deletions.
  1. +8 −12 account/
20 account/
@@ -2,24 +2,20 @@
class EmailAddressManager(models.Manager):
def add_email(self, user, email, **kwargs):
confirm = kwargs.pop("confirm", False)
- try:
- email_address = self.create(user=user, email=email, **kwargs)
- except IntegrityError:
- return None
- else:
- if confirm and not email_address.verified:
- email_address.send_confirmation()
- return email_address
+ email_address = self.create(user=user, email=email, **kwargs)
+ if confirm and not email_address.verified:
+ email_address.send_confirmation()
+ return email_address
def get_primary(self, user):
return self.get(user=user, primary=True)
except self.model.DoesNotExist:
return None
def get_users_for(self, email):
# this is a list rather than a generator because we probably want to
# do a len() on it right away
@@ -27,7 +23,7 @@ def get_users_for(self, email):
class EmailConfirmationManager(models.Manager):
def delete_expired_confirmations(self):
for confirmation in self.all():
if confirmation.key_expired():
Something went wrong with that request. Please try again.