From ffc4afda17d05e86d08377147847210b46afe0b2 Mon Sep 17 00:00:00 2001 From: hakanaktas0 <104701041+hakanaktas0@users.noreply.github.com> Date: Sun, 26 Nov 2023 00:32:11 +0300 Subject: [PATCH] basic user getter implemented --- project/backend/api/urls.py | 1 + project/backend/api/views.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/project/backend/api/urls.py b/project/backend/api/urls.py index 9f379413..b74a8013 100644 --- a/project/backend/api/urls.py +++ b/project/backend/api/urls.py @@ -7,6 +7,7 @@ path('signup/', SignUpAPIView.as_view(), name='signup'), path('login/', obtain_auth_token, name='login'), path('get_authenticated_user/', UserDetailAPI.as_view(), name='get_authenticated_user'), + path('get_authenticated_basic_user/', BasicUserDetailAPI.as_view(), name='get_authenticated_basic_user'), path('get_node/', NodeAPIView.as_view(), name='get_node'), path('search/', search, name='search'), path('get_profile_info/', get_profile, name='get_profile'), diff --git a/project/backend/api/views.py b/project/backend/api/views.py index 36eb034f..15193b5b 100644 --- a/project/backend/api/views.py +++ b/project/backend/api/views.py @@ -37,6 +37,17 @@ def get(self, request, *args, **kwargs): return Response(serializer.data) +class BasicUserDetailAPI(APIView): + authentication_classes = (TokenAuthentication,) + permission_classes = (IsAuthenticated,) + + def get(self, request, *args, **kwargs): + user = BasicUser.objects.get(id=request.user.id) + serializer = BasicUserSerializer(user) + + return Response(serializer.data) + + class ChangePasswordView(generics.UpdateAPIView): authentication_classes = (TokenAuthentication,) permission_classes = (IsAuthenticated,)