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

TokenCreateView inheritance update #756

Open
wants to merge 3 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: 0 additions & 7 deletions djoser/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,3 @@ def logout_user(request):
)
if settings.CREATE_SESSION_ON_LOGIN:
logout(request)


class ActionViewMixin:
def post(self, request, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
return self._action(serializer)
11 changes: 8 additions & 3 deletions djoser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
User = get_user_model()


class TokenCreateView(utils.ActionViewMixin, generics.GenericAPIView):
class TokenCreateView(generics.GenericAPIView):
"""Use this endpoint to obtain user authentication token."""

serializer_class = settings.SERIALIZERS.token_create
Expand All @@ -26,6 +26,11 @@ def _action(self, serializer):
data=token_serializer_class(token).data, status=status.HTTP_200_OK
)

def post(self, request, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
return self._action(serializer)


class TokenDestroyView(views.APIView):
"""Use this endpoint to logout user (remove user authentication token)."""
Expand Down Expand Up @@ -141,8 +146,8 @@ def perform_create(self, serializer, *args, **kwargs):
elif settings.SEND_CONFIRMATION_EMAIL:
settings.EMAIL.confirmation(self.request, context).send(to)

def perform_update(self, serializer, *args, **kwargs):
super().perform_update(serializer, *args, **kwargs)
def perform_update(self, serializer):
super().perform_update(serializer)
user = serializer.instance
signals.user_updated.send(
sender=self.__class__, user=user, request=self.request
Expand Down