Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4306,7 +4306,6 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
"secondary_email_enabled",
"year_of_birth",
"phone_number",
"activation_key",
"pending_name_change",
]
)
Expand Down
6 changes: 0 additions & 6 deletions openedx/core/djangoapps/user_api/accounts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ def to_representation(self, user): # lint-amnesty, pylint: disable=arguments-di
except ObjectDoesNotExist:
account_recovery = None

try:
activation_key = user.registration.activation_key
except ObjectDoesNotExist:
activation_key = None

data = {
"username": user.username,
"url": self.context.get('request').build_absolute_uri(
Expand All @@ -161,7 +156,6 @@ def to_representation(self, user): # lint-amnesty, pylint: disable=arguments-di
"date_joined": user.date_joined.replace(microsecond=0),
"last_login": user.last_login,
"is_active": user.is_active,
"activation_key": activation_key,
"bio": None,
"country": None,
"state": None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ def test_create_account(self):
'id': user.id,
'name': self.USERNAME,
'verified_name': None,
'activation_key': user.registration.activation_key,
'gender': None, 'goals': '',
'is_active': False,
'level_of_education': None,
Expand Down
20 changes: 10 additions & 10 deletions openedx/core/djangoapps/user_api/accounts/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ class TestAccountsAPI(FilteredQueryCountMixin, CacheIsolationTestCase, UserAPITe
"""

ENABLED_CACHES = ['default']
TOTAL_QUERY_COUNT = 26
FULL_RESPONSE_FIELD_COUNT = 29
TOTAL_QUERY_COUNT = 25
FULL_RESPONSE_FIELD_COUNT = 28

def setUp(self):
super().setUp()
Expand Down Expand Up @@ -488,19 +488,19 @@ def test_get_account_unknown_user(self, api_client, user):
("client", "user"),
)
@ddt.unpack
def test_regsitration_activation_key(self, api_client, user):
def test_regsitration_activation_key_not_exposed(self, api_client, user):
"""
Test that registration activation key has a value.
Test that activation_key is NOT returned in the account API response.
UserFactory does not auto-generate registration object for the test users.
It is created only for users that signup via email/API. Therefore, activation key has to be tested manually.
The activation_key is a secret used for email verification and must not be
exposed via the API, as doing so allows bypassing email verification.
"""
self.create_user_registration(self.user)

client = self.login_client(api_client, user)
response = self.send_get(client)

assert response.data["activation_key"] is not None
assert "activation_key" not in response.data

def test_successful_get_account_by_email(self):
"""
Expand Down Expand Up @@ -811,12 +811,12 @@ def verify_get_own_information(queries):
assert data['time_zone'] is None

self.client.login(username=self.user.username, password=TEST_PASSWORD)
verify_get_own_information(self._get_num_queries(24))
verify_get_own_information(self._get_num_queries(23))

# Now make sure that the user can get the same information, even if not active
self.user.is_active = False
self.user.save()
verify_get_own_information(self._get_num_queries(16))
verify_get_own_information(self._get_num_queries(15))

def test_get_account_empty_string(self):
"""
Expand All @@ -831,7 +831,7 @@ def test_get_account_empty_string(self):
legacy_profile.save()

self.client.login(username=self.user.username, password=TEST_PASSWORD)
with self.assertNumQueries(self._get_num_queries(24), table_ignorelist=WAFFLE_TABLES):
with self.assertNumQueries(self._get_num_queries(23), table_ignorelist=WAFFLE_TABLES):
response = self.send_get(self.client)
for empty_field in ("level_of_education", "gender", "country", "state", "bio",):
assert response.data[empty_field] is None
Expand Down
Loading