Repository navigation
fix(backend): reject duplicate email when creating a user via the API - #13100
Merged
SchrodingersGat merged 1 commit intoOct 26, 2026
Merged
Conversation
UserCreateSerializer did not check whether the email address was already in use (signup does, via allauth). Email based flows such as the login link look users up by email and silently send nothing when more than one user matches, while the API still reports success. Two existing tests reused one email for several users; give them distinct addresses.
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
SchrodingersGat
approved these changes
Oct 25, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13100 +/- ##
=======================================
Coverage 86.91% 86.91%
=======================================
Files 1557 1557
Lines 109441 109447 +6
Branches 12009 12009
=======================================
+ Hits 95117 95124 +7
+ Misses 14258 14257 -1
Partials 66 66
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Contributor
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
SchrodingersGat
pushed a commit
that referenced
this pull request
Oct 26, 2026
…#13100) (#13102) UserCreateSerializer did not check whether the email address was already in use (signup does, via allauth). Email based flows such as the login link look users up by email and silently send nothing when more than one user matches, while the API still reports success. Two existing tests reused one email for several users; give them distinct addresses. (cherry picked from commit bab82bf) Co-authored-by: Oren <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Creating a user from the Admin Center (
POST /api/user/,UserCreateSerializer) accepts an email address that another user already has. Self-signup rejects this through allauth's unique-email check, but this path never checks.The result is a silent failure later. The login-link flow (
GetSimpleLoginView.get_user) usesUser.objects.get(email=...). With two matches it logsMultiple users found with emailand sends nothing, but still returns{"status": "ok"}(which is correct for preventing account enumeration). The user is told the email was sent, and it never arrives.Seen on 1.6.1. An admin created a second account with the superuser's email address, and login links for that address stopped working.
Changes:
UserCreateSerializer.validaterejects an email that already exists (case-insensitive) onUser.emailor allauthEmailAddress, as a field error onemail.test_user_api: new assertion that a second user with the same email (different case) gets a 400. Two existing tests reused one email across several users; they now use distinct addresses.Testing:
python manage.py test usersgives 44 tests OK on sqlite. As a control, the new assertion fails againstmaster's serializer (201 != 400).Generated with Claude Code
https://claude.ai/code/session_01CR5gRLhFZQApAYRXBAtk3S