From bdbab31a17f9a190a06280cdbfeda285697781de Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Fri, 26 Jun 2020 03:12:56 +0000 Subject: [PATCH] Look up emails case insensitive --- apiserver/apiserver/api/serializers.py | 2 +- apiserver/apiserver/api/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apiserver/apiserver/api/serializers.py b/apiserver/apiserver/api/serializers.py index 35e748d..d8df89b 100644 --- a/apiserver/apiserver/api/serializers.py +++ b/apiserver/apiserver/api/serializers.py @@ -433,7 +433,7 @@ class MyPasswordChangeSerializer(PasswordChangeSerializer): class MyPasswordResetSerializer(PasswordResetSerializer): def validate_email(self, email): - if not User.objects.filter(email=email).exists(): + if not User.objects.filter(email__iexact=email).exists(): raise ValidationError('Not found.') return super().validate_email(email) diff --git a/apiserver/apiserver/api/utils.py b/apiserver/apiserver/api/utils.py index 1e36fd8..6ceebd1 100644 --- a/apiserver/apiserver/api/utils.py +++ b/apiserver/apiserver/api/utils.py @@ -231,7 +231,7 @@ def link_old_member(data, user): raise ValidationError(dict(email=msg)) try: - member = models.Member.objects.get(old_email=data['email']) + member = models.Member.objects.get(old_email__iexact=data['email']) except models.Member.DoesNotExist: msg = 'Unable to find email in old portal.' logger.info(msg) @@ -277,7 +277,7 @@ def link_old_member(data, user): def create_new_member(data, user): if old_models: old_members = old_models.Members.objects.using('old_portal') - if old_members.filter(email=data['email']).exists(): + if old_members.filter(email__iexact=data['email']).exists(): msg = 'Account was found in old portal.' logger.info(msg) raise ValidationError(dict(email=msg))