diff --git a/accounts/views/change_password.py b/accounts/views/change_password.py index 69f39ca..cb8579b 100644 --- a/accounts/views/change_password.py +++ b/accounts/views/change_password.py @@ -14,7 +14,7 @@ class ChangePasswordView(APIView): authentication_classes = (SessionAuthentication,) def post(self, request: HttpRequest): - data = request.POST + data = request.data serializer = ChangePasswordSerializer(data=data) if serializer.is_valid(raise_exception=True): diff --git a/accounts/views/login.py b/accounts/views/login.py index b89d48e..3a04da9 100644 --- a/accounts/views/login.py +++ b/accounts/views/login.py @@ -13,12 +13,12 @@ class LoginView(APIView): authentication_classes = (SessionAuthentication,) def post(self, request: HttpRequest): - data = request.POST - + data = request.data + print(data) serializer = LoginSerializer(data=data) - if serializer.is_valid(raise_exception=True): - user = serializer.get_user(data) - 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) \ No newline at end of file + serializer.is_valid(raise_exception=True) + user = serializer.get_user(data) + 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) \ No newline at end of file diff --git a/accounts/views/register.py b/accounts/views/register.py index 66f4f8a..5bdacc2 100644 --- a/accounts/views/register.py +++ b/accounts/views/register.py @@ -7,9 +7,10 @@ from django.http import HttpRequest class RegisterView(APIView): permission_classes = (permissions.AllowAny,) def post(self, request: HttpRequest): - serializer = RegisterSerialiser(data=request.POST) + data = request.data + serializer = RegisterSerialiser(data=data) if serializer.is_valid(raise_exception=True): - user = serializer.create(request.POST) + user = serializer.create(data) if user: return Response("user created", status=status.HTTP_201_CREATED) return Response(status=status.HTTP_400_BAD_REQUEST) \ No newline at end of file