Skip to content

Commit

Permalink
Fix for GWE-282-0 (#5126)
Browse files Browse the repository at this point in the history
* addressing GWE-282-0

* fix isort
  • Loading branch information
androolloyd authored and thelostone-mc committed Sep 4, 2019
1 parent 79d23ba commit b6263a4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/marketing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from django.conf import settings
from django.contrib import messages
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.models import User
from django.core.validators import validate_email
from django.db.models import Max
from django.http import Http404, HttpResponse
Expand Down Expand Up @@ -275,6 +276,10 @@ def email_settings(request, key):
preferred_language = request.POST.get('preferred_language')
validation_passed = True
try:
email_in_use = User.objects.filter(email=email) | User.objects.filter(profile__email=email)
email_used_marketing = EmailSubscriber.objects.filter(email=email).select_related('profile')
if (email_in_use or email_used_marketing) and (request.user.email != email or request.user.profile.email != email):
raise ValueError(f'{request.user} attempting to use an email which is already in use on the platform')
validate_email(email)
except Exception as e:
print(e)
Expand Down

0 comments on commit b6263a4

Please sign in to comment.