feat: return user id from login_refresh (#28905)

To enhance monitoring of login_refresh issues that happen
in the frontend, return user id as part of successful
refreshes.
This commit is contained in:
Robert Raposa
2021-10-04 11:00:07 -04:00
committed by GitHub
parent fa959f1ed9
commit e41520dbae
2 changed files with 3 additions and 0 deletions

View File

@@ -170,6 +170,7 @@ def get_response_with_refreshed_jwt_cookies(request, user):
response.content = json.dumps(
{
'success': True,
'user_id': user.id,
'response_epoch_seconds': current_time,
'response_http_date': http_date(current_time),
'expires': expires_date if expires_date else 'not-found',

View File

@@ -153,6 +153,8 @@ class CookieTests(TestCase):
self._set_use_jwt_cookie_header(self.request)
response = cookies_api.get_response_with_refreshed_jwt_cookies(self.request, self.user)
data = json.loads(response.content.decode('utf8').replace("'", '"'))
assert data['success'] is True
assert data['user_id'] == self.user.id
assert data['expires_epoch_seconds'] > 0
assert data['expires'] != 'not-found'
self._assert_cookies_present(response, cookies_api.JWT_COOKIE_NAMES)