feat(users): add /me/ endpoint for detail/update/delete user object
This commit is contained in:
@@ -9,7 +9,9 @@ from rest_framework.permissions import AllowAny, IsAuthenticated
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework_simplejwt.authentication import JWTAuthentication
|
||||
from rest_framework_simplejwt.tokens import RefreshToken
|
||||
from rest_framework.mixins import UpdateModelMixin, RetrieveModelMixin, DestroyModelMixin
|
||||
from rest_framework.viewsets import GenericViewSet
|
||||
|
||||
|
||||
from core.paginations.limit_offset import CustomLimitOffsetPagination
|
||||
|
||||
@@ -25,6 +27,7 @@ from apps.users.api.serializers import (
|
||||
LogoutSerializer,
|
||||
TokenPairSerializer,
|
||||
RegisterWithPasswordSerializer,
|
||||
UserProfileSerializer,
|
||||
)
|
||||
from apps.users.services.auth import (
|
||||
register_user_with_password,
|
||||
@@ -235,3 +238,11 @@ class UserListView(ListAPIView):
|
||||
@extend_schema(responses=UserListSerializer(many=True))
|
||||
def get(self, request, *args, **kwargs):
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
|
||||
class UserProfileViewSet(RetrieveModelMixin, UpdateModelMixin, DestroyModelMixin, GenericViewSet):
|
||||
serializer_class = UserProfileSerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get_object(self):
|
||||
return self.request.user
|
||||
|
||||
Reference in New Issue
Block a user