Skip to content
This repository has been archived by the owner on Sep 24, 2023. It is now read-only.

Commit

Permalink
remove previously-created empty UserEmail records
Browse files Browse the repository at this point in the history
Expand search for empty e-mail address records by searching for both
`''` and `' '`.
  • Loading branch information
barronhagerman committed Apr 20, 2018
1 parent 33d74bb commit 9c68949
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sentry_ldap_auth/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django_auth_ldap.backend import LDAPBackend
from django.conf import settings
from django.db.models import Q
from sentry.models import (
Organization,
OrganizationMember,
Expand Down Expand Up @@ -39,9 +40,9 @@ def get_or_create_user(self, username, ldap_user):
email = ''
else:
email = username + '@' + settings.AUTH_LDAP_DEFAULT_EMAIL_DOMAIN

# django-auth-ldap may have accidentally created an empty email address
UserEmail.objects.filter(user=user, email='').delete()
UserEmail.objects.filter(Q(email='') | Q(email=' '), user=user).delete()
if email:
UserEmail.objects.get_or_create(user=user, email=email)

Expand Down

0 comments on commit 9c68949

Please sign in to comment.