From bb576b16d80e6fbc5b761a39f0a22eb8a3de6a6a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 08:14:03 +1000 Subject: [PATCH] fix bug I introduced with automatic EmailAddress creation for LDAP users (#10347) (#10349) (cherry picked from commit fd57b5354b4a099382f525fad20bf5d59a009b48) Co-authored-by: Jacob Felknor --- src/backend/InvenTree/users/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/InvenTree/users/models.py b/src/backend/InvenTree/users/models.py index 3c59449cd1..033666aeb5 100644 --- a/src/backend/InvenTree/users/models.py +++ b/src/backend/InvenTree/users/models.py @@ -61,7 +61,10 @@ if settings.LDAP_AUTH: user.save() # if they got an email address from LDAP, create it now and make it the primary - if user.email: + if ( + user.email + and not EmailAddress.objects.filter(user=user, email=user.email).exists() + ): EmailAddress.objects.create(user=user, email=user.email, primary=True)