From 92c05dfc14805c8298810fe98ce76f72c5b68566 Mon Sep 17 00:00:00 2001 From: Agustin Barto Date: Thu, 11 Aug 2016 08:49:26 -0300 Subject: [PATCH 1/3] Add get_response to ObtainAuthToken --- rest_framework/authtoken/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rest_framework/authtoken/views.py b/rest_framework/authtoken/views.py index 0c6596a7e..063741af0 100644 --- a/rest_framework/authtoken/views.py +++ b/rest_framework/authtoken/views.py @@ -12,12 +12,16 @@ class ObtainAuthToken(APIView): renderer_classes = (renderers.JSONRenderer,) serializer_class = AuthTokenSerializer + def get_response(self, token, created): + return Response({'token': token.key}) + def post(self, request, *args, **kwargs): serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) user = serializer.validated_data['user'] token, created = Token.objects.get_or_create(user=user) - return Response({'token': token.key}) + response = self.get_response(token, created) + return response -obtain_auth_token = ObtainAuthToken.as_view() +obtain_auth_token = ObtainAuthToken.as_view \ No newline at end of file From 11ce600c492b2a0b235db29fa76c81bb765e3256 Mon Sep 17 00:00:00 2001 From: Agustin Barto Date: Thu, 11 Aug 2016 09:12:15 -0300 Subject: [PATCH 2/3] Add missing new line at end of file --- rest_framework/authtoken/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/authtoken/views.py b/rest_framework/authtoken/views.py index 063741af0..731511cc2 100644 --- a/rest_framework/authtoken/views.py +++ b/rest_framework/authtoken/views.py @@ -24,4 +24,4 @@ class ObtainAuthToken(APIView): return response -obtain_auth_token = ObtainAuthToken.as_view \ No newline at end of file +obtain_auth_token = ObtainAuthToken.as_view From d8b509ac8c16e2c5c072fab904928c611f8b8dc8 Mon Sep 17 00:00:00 2001 From: Agustin Barto Date: Thu, 11 Aug 2016 09:21:47 -0300 Subject: [PATCH 3/3] Fix typo in as_view invocation --- rest_framework/authtoken/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/authtoken/views.py b/rest_framework/authtoken/views.py index 731511cc2..9ed7b5950 100644 --- a/rest_framework/authtoken/views.py +++ b/rest_framework/authtoken/views.py @@ -24,4 +24,4 @@ class ObtainAuthToken(APIView): return response -obtain_auth_token = ObtainAuthToken.as_view +obtain_auth_token = ObtainAuthToken.as_view()