Default authentication on endpoints
Ik was er namelijk alweer eentje vergeten dus heh.
This commit is contained in:
@@ -2,20 +2,14 @@ from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from django.contrib.auth.models import User
|
||||
from playlist.serializers import UserSerializer
|
||||
from rest_framework.authentication import SessionAuthentication
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
|
||||
class UserListView(APIView):
|
||||
authentication_classes = [SessionAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
def get(self, request):
|
||||
users = User.objects.all()
|
||||
serializer = UserSerializer(users, many=True, context={'request': request})
|
||||
return Response(serializer.data)
|
||||
|
||||
class UserDetailView(APIView):
|
||||
authentication_classes = [SessionAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
def get(self, request, id):
|
||||
user = User.objects.get(pk=id)
|
||||
serializer = UserSerializer(user, context={'request': request})
|
||||
|
||||
Reference in New Issue
Block a user