Skip to content

Commit f6985d5

Browse files
Use Django's validate_email for co-speaker email validation
Co-authored-by: Marco Acierno <marcoacierno@users.noreply.github.com>
1 parent 3696978 commit f6985d5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

backend/api/submissions/mutations.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from urllib.parse import urljoin
22
from django.conf import settings
3+
from django.core.exceptions import ValidationError
4+
from django.core.validators import validate_email
35
from conferences.frontend import trigger_frontend_revalidate
46
from grants.tasks import get_name
57
from notifications.models import EmailTemplate, EmailTemplateIdentifier
@@ -217,8 +219,10 @@ def validate(self, conference: Conference, current_user=None):
217219
errors.add_error("co_speaker_emails", f"Duplicate email: {email}")
218220
seen_emails.add(email_lower)
219221

220-
# Validate email format (basic check)
221-
if "@" not in email or "." not in email:
222+
# Validate email format using Django's validate_email
223+
try:
224+
validate_email(email)
225+
except ValidationError:
222226
errors.add_error("co_speaker_emails", f"Invalid email format: {email}")
223227

224228
# Check if user is trying to add themselves as co-speaker

0 commit comments

Comments
 (0)