From 97fb51ce67335de3679bb38db087323455ec8515 Mon Sep 17 00:00:00 2001 From: Sharon Wang Date: Tue, 15 Dec 2020 15:22:28 -0500 Subject: [PATCH] sos --- openedx/core/djangoapps/user_authn/cookies.py | 10 ++++++++++ .../core/djangoapps/user_authn/tests/test_cookies.py | 1 + 2 files changed, 11 insertions(+) diff --git a/openedx/core/djangoapps/user_authn/cookies.py b/openedx/core/djangoapps/user_authn/cookies.py index 79141b6a86..ae5dfc49c4 100644 --- a/openedx/core/djangoapps/user_authn/cookies.py +++ b/openedx/core/djangoapps/user_authn/cookies.py @@ -23,6 +23,7 @@ from openedx.core.djangoapps.oauth_dispatch.jwt import create_jwt_from_token from openedx.core.djangoapps.user_api.accounts.utils import retrieve_last_sitewide_block_completed from openedx.core.djangoapps.user_authn.exceptions import AuthFailedError from common.djangoapps.util.json_request import JsonResponse +from common.djangoapps.user_api.accounts.image_helpers import get_profile_image_urls_for_user log = logging.getLogger(__name__) @@ -195,9 +196,16 @@ def _set_deprecated_user_info_cookie(response, request, user, cookie_settings): } } """ + image_urls = [] user_info = _get_user_info_cookie_data(request, user) + + if user.profile and user.profile.has_profile_image: + image_urls = get_profile_image_urls_for_user(request, user) + print('image urls') + print(image_urls) response.set_cookie( settings.EDXMKTG_USER_INFO_COOKIE_NAME, + json.dumps(image_urls), json.dumps(user_info), **cookie_settings ) @@ -249,6 +257,8 @@ def _get_user_info_cookie_data(request, user): for url_name, url_path in six.iteritems(header_urls): header_urls[url_name] = request.build_absolute_uri(url_path) + print(user) + user_info = { 'version': settings.EDXMKTG_USER_INFO_COOKIE_VERSION, 'username': user.username, diff --git a/openedx/core/djangoapps/user_authn/tests/test_cookies.py b/openedx/core/djangoapps/user_authn/tests/test_cookies.py index ecef23a646..0cffde7617 100644 --- a/openedx/core/djangoapps/user_authn/tests/test_cookies.py +++ b/openedx/core/djangoapps/user_authn/tests/test_cookies.py @@ -94,6 +94,7 @@ class CookieTests(TestCase): } self.assertDictEqual(actual, expected) + self.assertEqual(0,1) def test_set_logged_in_cookies_anonymous_user(self): anonymous_user = AnonymousUserFactory()