diff --git a/openedx/core/djangoapps/user_authn/views/login.py b/openedx/core/djangoapps/user_authn/views/login.py index 6a012d8d212d..72c23f9199a1 100644 --- a/openedx/core/djangoapps/user_authn/views/login.py +++ b/openedx/core/djangoapps/user_authn/views/login.py @@ -684,6 +684,8 @@ def login_user(request, api_version="v1"): # pylint: disable=too-many-statement email_or_username_key = "email" if api_version == API_V1 else "email_or_username" email_or_username = request.POST.get(email_or_username_key, None) email_or_username = possibly_authenticated_user.email if possibly_authenticated_user else email_or_username + if error_code == "inactive-user" and user: + email_or_username = user.email response_content["email"] = email_or_username except VulnerablePasswordError as error: response_content = error.get_response() diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_login.py b/openedx/core/djangoapps/user_authn/views/tests/test_login.py index 4e4d0a9e8894..e969b8501130 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_login.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_login.py @@ -439,6 +439,8 @@ def test_login_not_activated_with_correct_credentials(self): self.password, ) self._assert_response(response, success=False, error_code="inactive-user") + response_dict = json.loads(response.content.decode('utf-8')) + assert response_dict["email"] == self.user_email self._assert_audit_log(mock_audit_log, 'warning', ['Login failed', 'Account not active for user']) @patch('openedx.core.djangoapps.user_authn.views.login._log_and_raise_inactive_user_auth_error')