From dc6c39bd0a3a1ba49ab9d69bbe41b432801d8b5b Mon Sep 17 00:00:00 2001 From: amirbolouri87 Date: Sun, 21 Apr 2024 23:27:19 +0330 Subject: [PATCH 1/4] add response message when token black listed. --- rest_framework_simplejwt/views.py | 6 ++++++ tests/test_serializers.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rest_framework_simplejwt/views.py b/rest_framework_simplejwt/views.py index c6523da0f..442b8e34b 100644 --- a/rest_framework_simplejwt/views.py +++ b/rest_framework_simplejwt/views.py @@ -116,5 +116,11 @@ 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['Token detail'] = 'Token blacklisted' + + return Response(serializer_data, status=response.status_code) token_blacklist = TokenBlacklistView.as_view() diff --git a/tests/test_serializers.py b/tests/test_serializers.py index 322d1cd9d..532e6d8fc 100644 --- a/tests/test_serializers.py +++ b/tests/test_serializers.py @@ -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) From 2da70b063ffcca4630aeb573e9d938d3ab9d8968 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 21 Apr 2024 20:00:37 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- rest_framework_simplejwt/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rest_framework_simplejwt/views.py b/rest_framework_simplejwt/views.py index 442b8e34b..93e42e889 100644 --- a/rest_framework_simplejwt/views.py +++ b/rest_framework_simplejwt/views.py @@ -119,8 +119,9 @@ class TokenBlacklistView(TokenViewBase): def post(self, request: Request, *args, **kwargs) -> Response: response = super().post(request, *args, **kwargs) serializer_data = response.data - serializer_data['Token detail'] = 'Token blacklisted' + serializer_data["Token detail"] = "Token blacklisted" return Response(serializer_data, status=response.status_code) + token_blacklist = TokenBlacklistView.as_view() From 1dd152a766f09fad3028467fcd7d6a8018c98a5a Mon Sep 17 00:00:00 2001 From: amirbolouri87 Date: Mon, 22 Apr 2024 09:57:38 +0330 Subject: [PATCH 3/4] fix mistake adding key of message --- rest_framework_simplejwt/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework_simplejwt/views.py b/rest_framework_simplejwt/views.py index 442b8e34b..83b97a85b 100644 --- a/rest_framework_simplejwt/views.py +++ b/rest_framework_simplejwt/views.py @@ -119,7 +119,7 @@ class TokenBlacklistView(TokenViewBase): def post(self, request: Request, *args, **kwargs) -> Response: response = super().post(request, *args, **kwargs) serializer_data = response.data - serializer_data['Token detail'] = 'Token blacklisted' + serializer_data['message'] = 'Token blacklisted' return Response(serializer_data, status=response.status_code) From 12c31c6c2256359676457fbb2cd1a05cdbb739d4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 06:31:04 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- rest_framework_simplejwt/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rest_framework_simplejwt/views.py b/rest_framework_simplejwt/views.py index 83b97a85b..82ee8cb7f 100644 --- a/rest_framework_simplejwt/views.py +++ b/rest_framework_simplejwt/views.py @@ -119,8 +119,9 @@ class TokenBlacklistView(TokenViewBase): def post(self, request: Request, *args, **kwargs) -> Response: response = super().post(request, *args, **kwargs) serializer_data = response.data - serializer_data['message'] = 'Token blacklisted' + serializer_data["message"] = "Token blacklisted" return Response(serializer_data, status=response.status_code) + token_blacklist = TokenBlacklistView.as_view()