mirror of
https://github.com/suitenumerique/meet.git
synced 2026-09-03 06:08:29 +00:00
🐛(backend) prevent duplicate pending users on concurrent requests
Fix a race condition in the external viewset where concurrent requests could create multiple pending users with the same email address. No database constraint enforced email uniqueness for pending users, allowing duplicates to be created under load. This caused issues during user reconciliation, which expects a single matching pending user and raises a warning when multiple records are found. Add a narrowly scoped migration to enforce the uniqueness constraint and address the identified issue.
This commit is contained in:
committed by
aleb_the_flash
parent
28f652e035
commit
a8b79740e9
@@ -346,8 +346,11 @@ def test_authentication_getter_existing_user_change_fields(
|
||||
|
||||
# One and only one additional update query when a field has changed
|
||||
# Note: .save() triggers uniqueness validation queries for unique fields,
|
||||
# adding extra SELECT queries before the UPDATE (e.g., checking unique=True on 'sub')
|
||||
with django_assert_num_queries(3):
|
||||
# adding extra SELECT queries before the UPDATE:
|
||||
# - unique=True on 'sub'
|
||||
# - unique=True on 'admin_email'
|
||||
# - partial unique index 'unique_email_when_sub_is_null'
|
||||
with django_assert_num_queries(5):
|
||||
authenticated_user = klass.get_or_create_user(
|
||||
access_token="test-token", id_token=None, payload=None
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user