Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add response message when token black listed. #800

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions rest_framework_simplejwt/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,12 @@ class TokenBlacklistView(TokenViewBase):

_serializer_class = api_settings.TOKEN_BLACKLIST_SERIALIZER

def post(self, request: Request, *args, **kwargs) -> Response:
response = super().post(request, *args, **kwargs)
serializer_data = response.data
serializer_data["message"] = "Token blacklisted"

return Response(serializer_data, status=response.status_code)


token_blacklist = TokenBlacklistView.as_view()
2 changes: 1 addition & 1 deletion tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def test_it_should_return_nothing_if_everything_ok(self):
fake_aware_utcnow.return_value = now
self.assertTrue(s.is_valid())

self.assertDictEqual(s.validated_data, {})
self.assertDictEqual(s.validated_data, {"message": "Token blacklisted"})

def test_it_should_blacklist_refresh_token_if_everything_ok(self):
self.assertEqual(OutstandingToken.objects.count(), 0)
Expand Down
Loading