Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Return decoded payload in authenticate #370

Merged
merged 3 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rest_framework_jwt/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
7 changes: 7 additions & 0 deletions tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ def test_post_form_passing_jwt_auth(self):

self.assertEqual(response.status_code, status.HTTP_200_OK)

# 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
Expand Down