diff --git a/openedx/core/djangoapps/user_authn/views/register.py b/openedx/core/djangoapps/user_authn/views/register.py index 8d6752187f5e..083a821b9314 100644 --- a/openedx/core/djangoapps/user_authn/views/register.py +++ b/openedx/core/djangoapps/user_authn/views/register.py @@ -591,7 +591,10 @@ def post(self, request): redirect_to, root_url = get_next_url_for_login_page(request, include_host=True) redirect_url = get_redirect_url_with_host(root_url, redirect_to) - response = self._create_response(request, {}, status_code=200, redirect_url=redirect_url) + authenticated_user = {'username': user.username, 'user_id': user.id} + response = self._create_response( + request, {'authenticated_user': authenticated_user}, status_code=200, redirect_url=redirect_url + ) set_logged_in_cookies(request, response, user) if not user.is_active and settings.SHOW_ACCOUNT_ACTIVATION_CTA and not settings.MARKETING_EMAILS_OPT_IN: response.set_cookie( diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_register.py b/openedx/core/djangoapps/user_authn/views/tests/test_register.py index 69c4c9ffd090..0bc05545f775 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_register.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_register.py @@ -2238,6 +2238,12 @@ def test_register_success_with_redirect(self, next_url, course_id, expected_redi HTTP_ACCEPT='*/*', ) self._assert_redirect_url(response, expected_redirect) + assert response.status_code == 200 + + # Check that authenticated user details are also returned in + # the response for successful registration + decoded_response = json.loads(response.content.decode('utf-8')) + assert decoded_response['authenticated_user'] == {'username': self.USERNAME, 'user_id': 1} @mock.patch('openedx.core.djangoapps.user_authn.views.register._record_is_marketable_attribute') def test_logs_for_error_when_setting_is_marketable_attribute(self, set_is_marketable_attr):