Skip to content

Commit

Permalink
Remove second response serializaton
Browse files Browse the repository at this point in the history
Remove the second response serialization because it breaks custom
response payload handlers. Fixes Styria-Digital#10
  • Loading branch information
paymog committed Dec 12, 2019
1 parent ccbf262 commit 2dca689
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,6 @@ python_boilerplate/
# Sqlite3
*.sqlite3

# virtual environment stuff
venv/
.python-version
4 changes: 4 additions & 0 deletions changelog.d/22.bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Remove serialization on response data in `BaseJSONWebTokenAPIView` because it
breaks custom response payload handlers which add extra data to the response
payload. This change aligns this fork more closely with the original and makes
it easier to use this fork as a drop-in replacement for the original.
7 changes: 1 addition & 6 deletions src/rest_framework_jwt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,4 @@ def jwt_create_response_payload(
Note that we are using `pk` field here - this is for forward compatibility
with drf add-ons that might require `pk` field in order (eg. jsonapi).
"""

response_payload = namedtuple('ResponsePayload', 'pk token')
response_payload.pk = issued_at
response_payload.token = token

return response_payload
return {'pk': issued_at, 'token': token}
5 changes: 1 addition & 4 deletions src/rest_framework_jwt/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ def post(self, request, *args, **kwargs):
response_data = JSONWebTokenAuthentication. \
jwt_create_response_payload(token, user, request, issued_at)

response_serializer = self.get_serializer(
response_data, context={'request': request}
)
response = Response(response_serializer.data)
response = Response(response_data)

if api_settings.JWT_AUTH_COOKIE:
expiration = (
Expand Down

0 comments on commit 2dca689

Please sign in to comment.