forked from CGM_Public/pretix_original
Always query emails case-insensitively
This commit is contained in:
@@ -120,7 +120,7 @@ class RegistrationForm(forms.Form):
|
|||||||
|
|
||||||
def clean_email(self):
|
def clean_email(self):
|
||||||
email = self.cleaned_data['email']
|
email = self.cleaned_data['email']
|
||||||
if User.objects.filter(email=email).exists():
|
if User.objects.filter(email__iexact=email).exists():
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
self.error_messages['duplicate_email'],
|
self.error_messages['duplicate_email'],
|
||||||
code='duplicate_email'
|
code='duplicate_email'
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class UserSettingsForm(forms.ModelForm):
|
|||||||
|
|
||||||
def clean_email(self):
|
def clean_email(self):
|
||||||
email = self.cleaned_data['email']
|
email = self.cleaned_data['email']
|
||||||
if User.objects.filter(Q(email=email) & ~Q(pk=self.instance.pk)).exists():
|
if User.objects.filter(Q(email__iexact=email) & ~Q(pk=self.instance.pk)).exists():
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
self.error_messages['duplicate_identifier'],
|
self.error_messages['duplicate_identifier'],
|
||||||
code='duplicate_identifier',
|
code='duplicate_identifier',
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ class WaitingListEntry(LoggedModel):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def clean_duplicate(email, item, variation, subevent, pk):
|
def clean_duplicate(email, item, variation, subevent, pk):
|
||||||
if WaitingListEntry.objects.filter(
|
if WaitingListEntry.objects.filter(
|
||||||
item=item, variation=variation, email=email, voucher__isnull=True, subevent=subevent
|
item=item, variation=variation, email__iexact=email, voucher__isnull=True, subevent=subevent
|
||||||
).exclude(pk=pk).exists():
|
).exclude(pk=pk).exists():
|
||||||
raise ValidationError(_('You are already on this waiting list! We will notify '
|
raise ValidationError(_('You are already on this waiting list! We will notify '
|
||||||
'you as soon as we have a ticket available for you.'))
|
'you as soon as we have a ticket available for you.'))
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class UserEditForm(forms.ModelForm):
|
|||||||
|
|
||||||
def clean_email(self):
|
def clean_email(self):
|
||||||
email = self.cleaned_data['email']
|
email = self.cleaned_data['email']
|
||||||
if User.objects.filter(Q(email=email) & ~Q(pk=self.instance.pk)).exists():
|
if User.objects.filter(Q(email__iexact=email) & ~Q(pk=self.instance.pk)).exists():
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
self.error_messages['duplicate_identifier'],
|
self.error_messages['duplicate_identifier'],
|
||||||
code='duplicate_identifier',
|
code='duplicate_identifier',
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ class Forgot(TemplateView):
|
|||||||
has_redis = settings.HAS_REDIS
|
has_redis = settings.HAS_REDIS
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user = User.objects.get(email=email)
|
user = User.objects.get(email__iexact=email)
|
||||||
|
|
||||||
if has_redis:
|
if has_redis:
|
||||||
from django_redis import get_redis_connection
|
from django_redis import get_redis_connection
|
||||||
|
|||||||
@@ -575,9 +575,9 @@ class TeamMemberView(OrganizerDetailViewMixin, OrganizerPermissionRequiredMixin,
|
|||||||
elif "user" in self.request.POST and self.add_form.is_valid() and self.add_form.has_changed():
|
elif "user" in self.request.POST and self.add_form.is_valid() and self.add_form.has_changed():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user = User.objects.get(email=self.add_form.cleaned_data['user'])
|
user = User.objects.get(email__iexact=self.add_form.cleaned_data['user'])
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
if self.object.invites.filter(email=self.add_form.cleaned_data['user']).exists():
|
if self.object.invites.filter(email__iexact=self.add_form.cleaned_data['user']).exists():
|
||||||
messages.error(self.request, _('This user already has been invited for this team.'))
|
messages.error(self.request, _('This user already has been invited for this team.'))
|
||||||
return self.get(request, *args, **kwargs)
|
return self.get(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class ResendLinkView(EventViewMixin, TemplateView):
|
|||||||
else:
|
else:
|
||||||
rc.setex('pretix_resend_{}'.format(user), 3600 * 24, '1')
|
rc.setex('pretix_resend_{}'.format(user), 3600 * 24, '1')
|
||||||
|
|
||||||
orders = self.request.event.orders.filter(email=user)
|
orders = self.request.event.orders.filter(email__iexact=user)
|
||||||
order_context = []
|
order_context = []
|
||||||
|
|
||||||
for order in orders:
|
for order in orders:
|
||||||
|
|||||||
Reference in New Issue
Block a user