add: profile avatar

This commit is contained in:
2023-12-06 15:19:41 +01:00
parent 910644a804
commit 9b6c5547f0
16 changed files with 141 additions and 37 deletions

View File

@ -13,7 +13,7 @@ class EditView(APIView):
authentication_classes = (SessionAuthentication,)
def get(self, request: HttpRequest):
return Response({"username": request.user.username})
return Response({"username": request.user.username, "id": request.user.pk})
def patch(self, request: HttpRequest):
data: dict = request.data

View File

@ -13,4 +13,6 @@ class LoggedView(APIView):
authentication_classes = (SessionAuthentication,)
def get(self, request: HttpRequest):
return Response(str(request.user.is_authenticated), status=status.HTTP_200_OK)
if (request.user.is_authenticated):
return Response({'id': request.user.pk}, status=status.HTTP_200_OK)
return Response('false', status=status.HTTP_200_OK)

View File

@ -20,4 +20,4 @@ class LoginView(APIView):
if user is None:
return Response({'user': ['Username or password wrong.']}, status.HTTP_200_OK)
login(request, user)
return Response('user connected', status=status.HTTP_200_OK)
return Response({'id': user.pk}, status=status.HTTP_200_OK)