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

[BugFix] Verify all members of team have a allowed email domain #3591

Merged
merged 4 commits into from
Sep 3, 2021
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
22 changes: 12 additions & 10 deletions apps/challenges/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,16 +336,18 @@ def add_participant_team_to_challenge(
# Check if user is in allowed list.
user_email = request.user.email
if len(challenge.allowed_email_domains) > 0:
if not is_user_in_allowed_email_domains(user_email, challenge_pk):
message = "Sorry, users with {} email domain(s) are only allowed to participate in this challenge."
domains = ""
for domain in challenge.allowed_email_domains:
domains = "{}{}{}".format(domains, "/", domain)
domains = domains[1:]
response_data = {"error": message.format(domains)}
return Response(
response_data, status=status.HTTP_406_NOT_ACCEPTABLE
)
domains = ""
for domain in challenge.allowed_email_domains:
domains = "{}{}{}".format(domains, "/", domain)
domains = domains[1:]
for participant_email in participant_team.get_all_participants_email():
if not is_user_in_allowed_email_domains(participant_email, challenge_pk):
message = "Sorry, team consisting of users with non-{} email domain(s) are not allowed \
to participate in this challenge."
response_data = {"error": message.format(domains)}
return Response(
response_data, status=status.HTTP_406_NOT_ACCEPTABLE
)

# Check if user is in blocked list.
if is_user_in_blocked_email_domains(user_email, challenge_pk):
Expand Down