Fix race-condition when creating a customer

This commit is contained in:
Richard Schreiber
2025-03-12 12:23:04 +01:00
parent 032be74d77
commit fa0aa71c5c
+13 -10
View File
@@ -257,18 +257,21 @@ class RegistrationForm(forms.Form):
return self.cleaned_data
def create(self):
customer = self.request.organizer.customers.create(
customer, created = self.request.organizer.customers.get_or_create(
email=self.cleaned_data['email'],
name_parts=self.cleaned_data['name_parts'],
phone=self.cleaned_data.get('phone'),
is_active=True,
is_verified=False,
locale=get_language_without_region(),
defaults={
"name_parts":self.cleaned_data['name_parts'],
"phone":self.cleaned_data.get('phone'),
"is_active":True,
"is_verified":False,
"locale":get_language_without_region(),
}
)
customer.set_unusable_password()
customer.save()
customer.log_action('pretix.customer.created', {})
customer.send_activation_mail()
if created:
customer.set_unusable_password()
customer.save()
customer.log_action('pretix.customer.created', {})
customer.send_activation_mail()
return customer