Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for GWE-282-0 #5126

Merged
merged 2 commits into from
Sep 4, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/marketing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from django.conf import settings
from django.contrib import messages
from django.contrib.auth.models import User
from django.contrib.admin.views.decorators import staff_member_required
from django.core.validators import validate_email
from django.db.models import Max
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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

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