Skip to content

Commit

Permalink
feat: add user details to registration response (#33078)
Browse files Browse the repository at this point in the history
  • Loading branch information
zainab-amir committed Aug 23, 2023
1 parent a4b11c0 commit 45fd0b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion openedx/core/djangoapps/user_authn/views/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 45fd0b5

Please sign in to comment.