Skip to content

Commit

Permalink
Merge pull request #6132 from edx/sanchez/fix_age_verification
Browse files Browse the repository at this point in the history
Only allow users who turned 13 before this year began to opt in.
  • Loading branch information
Stephen Sanchez committed Dec 4, 2014
2 parents 150fddd + f993a48 commit dd77ec0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/djangoapps/user_api/api/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def update_email_opt_in(username, org, optin):
profile = UserProfile.objects.get(user=user)
of_age = (
profile.year_of_birth is None or # If year of birth is not set, we assume user is of age.
datetime.datetime.now(UTC).year - profile.year_of_birth >= # pylint: disable=maybe-no-member
datetime.datetime.now(UTC).year - profile.year_of_birth > # pylint: disable=maybe-no-member
getattr(settings, 'EMAIL_OPTIN_MINIMUM_AGE', 13)
)

Expand Down
7 changes: 5 additions & 2 deletions common/djangoapps/user_api/tests/test_profile_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ def test_update_and_retrieve_preference_info(self):
# Check that a 32-year old can opt-out
(32, False, u"False"),
# Check that someone 13 years old can opt-in
(13, True, u"True"),
# Check that someone 14 years old can opt-in
(14, True, u"True"),
# Check that someone 13 years old cannot opt-in (must have turned 13 before this year)
(13, True, u"False"),
# Check that someone 12 years old cannot opt-in
(12, True, u"False")
Expand Down

0 comments on commit dd77ec0

Please sign in to comment.