diff --git a/project/backend/api/urls.py b/project/backend/api/urls.py index 2e1f76b3..6928cbac 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 c58448a8..03907d8b 100644 --- a/project/backend/api/views.py +++ b/project/backend/api/views.py @@ -37,6 +37,19 @@ 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(user_id=request.user.id) + + return JsonResponse({'basic_user_id':user.id, + 'bio':user.bio, + 'email_notification_preference': user.email_notification_preference, + 'show_activity_preference':user.show_activity_preference},status=200) + + class ChangePasswordView(generics.UpdateAPIView): authentication_classes = (TokenAuthentication,) permission_classes = (IsAuthenticated,)