diff --git a/apps/users/serializers.py b/apps/users/serializers.py index 34fcd72..7f60a24 100644 --- a/apps/users/serializers.py +++ b/apps/users/serializers.py @@ -19,3 +19,12 @@ def create(self, validated_data): return user except Exception as e: raise serializers.ValidationError(str(e)) + + +class UserSerializer(serializers.ModelSerializer): + class Meta: + model = User + fields = ( + "id", + "email", + ) diff --git a/apps/users/urls.py b/apps/users/urls.py index 3893743..a7664dc 100644 --- a/apps/users/urls.py +++ b/apps/users/urls.py @@ -1,9 +1,11 @@ from django.urls import path from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView -from apps.users.views import SignupView +from apps.users.views import SignupView, UserDetailView + urlpatterns = [ path("token/", TokenObtainPairView.as_view(), name="token_obtain_pair"), path("token/refresh/", TokenRefreshView.as_view(), name="token_refresh"), path("signup/", SignupView.as_view(), name="signup"), + path("user/", UserDetailView.as_view(), name="user"), ] diff --git a/apps/users/views.py b/apps/users/views.py index 325c1c0..065885b 100644 --- a/apps/users/views.py +++ b/apps/users/views.py @@ -9,3 +9,8 @@ class SignupView(generics.CreateAPIView): queryset = User.objects.all() serializer_class = SignupSerializer + + +class UserDetailView(generics.RetrieveAPIView): + queryset = User.objects.all() + serializer_class = SignupSerializer diff --git a/core/settings/base.py b/core/settings/base.py index 9a15c80..5bf8bec 100644 --- a/core/settings/base.py +++ b/core/settings/base.py @@ -127,7 +127,7 @@ "DEFAULT_AUTHENTICATION_CLASSES": ( "rest_framework_simplejwt.authentication.JWTAuthentication", ), - "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.AllowAny",), + "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",), } SIMPLE_JWT = {