fix: update registration api response and replace username with name (#34226)

Update api registration api response and add full_name in response
This commit is contained in:
Blue
2024-02-14 13:51:25 +05:00
committed by GitHub
parent 2f2ed4d6cb
commit 4bd0981e68
2 changed files with 7 additions and 2 deletions

View File

@@ -590,7 +590,7 @@ class RegistrationView(APIView):
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)
authenticated_user = {'username': user.username, 'user_id': user.id}
authenticated_user = {'username': user.username, 'full_name': user.profile.name, 'user_id': user.id}
response = self._create_response(
request, {'authenticated_user': authenticated_user}, status_code=200, redirect_url=redirect_url
)

View File

@@ -2258,6 +2258,11 @@ class RegistrationViewTestV2(RegistrationViewTestV1):
@override_settings(LOGIN_REDIRECT_WHITELIST=['openedx.service'])
@skip_unless_lms
def test_register_success_with_redirect(self, next_url, course_id, expected_redirect):
expected_response = {
'username': self.USERNAME,
'full_name': self.NAME,
'user_id': 1
}
post_params = {
"email": self.EMAIL,
"name": self.NAME,
@@ -2282,7 +2287,7 @@ class RegistrationViewTestV2(RegistrationViewTestV1):
# 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}
assert decoded_response['authenticated_user'] == expected_response
@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):