diff --git a/rest_framework_jwt/authentication.py b/rest_framework_jwt/authentication.py index 86b50b90..776ba422 100644 --- a/rest_framework_jwt/authentication.py +++ b/rest_framework_jwt/authentication.py @@ -42,7 +42,7 @@ def authenticate(self, request): user = self.authenticate_credentials(payload) - return (user, jwt_value) + return (user, payload) def authenticate_credentials(self, payload): """ diff --git a/tests/test_authentication.py b/tests/test_authentication.py index 588ac658..b0c8de62 100644 --- a/tests/test_authentication.py +++ b/tests/test_authentication.py @@ -64,6 +64,13 @@ def test_post_form_passing_jwt_auth(self): self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.content, b'mockview-post') + # Ensure `authenticate` returned the decoded payload. + self.assertEqual(response.wsgi_request.user, self.user) + payload = response.wsgi_request.auth + self.assertIsInstance(payload, dict) + self.assertEqual(set(payload.keys()), { + 'user_id', 'username', 'exp', 'email'}) + def test_post_json_passing_jwt_auth(self): """ Ensure POSTing JSON over JWT auth with correct credentials