fix: use the right post data
This commit is contained in:
parent
b9728dcb06
commit
9aa724e19e
@ -14,7 +14,7 @@ class ChangePasswordView(APIView):
|
|||||||
authentication_classes = (SessionAuthentication,)
|
authentication_classes = (SessionAuthentication,)
|
||||||
|
|
||||||
def post(self, request: HttpRequest):
|
def post(self, request: HttpRequest):
|
||||||
data = request.POST
|
data = request.data
|
||||||
|
|
||||||
serializer = ChangePasswordSerializer(data=data)
|
serializer = ChangePasswordSerializer(data=data)
|
||||||
if serializer.is_valid(raise_exception=True):
|
if serializer.is_valid(raise_exception=True):
|
||||||
|
@ -13,10 +13,10 @@ class LoginView(APIView):
|
|||||||
authentication_classes = (SessionAuthentication,)
|
authentication_classes = (SessionAuthentication,)
|
||||||
|
|
||||||
def post(self, request: HttpRequest):
|
def post(self, request: HttpRequest):
|
||||||
data = request.POST
|
data = request.data
|
||||||
|
print(data)
|
||||||
serializer = LoginSerializer(data=data)
|
serializer = LoginSerializer(data=data)
|
||||||
if serializer.is_valid(raise_exception=True):
|
serializer.is_valid(raise_exception=True)
|
||||||
user = serializer.get_user(data)
|
user = serializer.get_user(data)
|
||||||
if user is None:
|
if user is None:
|
||||||
return Response({'user': ['Username or password wrong.']}, status.HTTP_200_OK)
|
return Response({'user': ['Username or password wrong.']}, status.HTTP_200_OK)
|
||||||
|
@ -7,9 +7,10 @@ from django.http import HttpRequest
|
|||||||
class RegisterView(APIView):
|
class RegisterView(APIView):
|
||||||
permission_classes = (permissions.AllowAny,)
|
permission_classes = (permissions.AllowAny,)
|
||||||
def post(self, request: HttpRequest):
|
def post(self, request: HttpRequest):
|
||||||
serializer = RegisterSerialiser(data=request.POST)
|
data = request.data
|
||||||
|
serializer = RegisterSerialiser(data=data)
|
||||||
if serializer.is_valid(raise_exception=True):
|
if serializer.is_valid(raise_exception=True):
|
||||||
user = serializer.create(request.POST)
|
user = serializer.create(data)
|
||||||
if user:
|
if user:
|
||||||
return Response("user created", status=status.HTTP_201_CREATED)
|
return Response("user created", status=status.HTTP_201_CREATED)
|
||||||
return Response(status=status.HTTP_400_BAD_REQUEST)
|
return Response(status=status.HTTP_400_BAD_REQUEST)
|
Loading…
Reference in New Issue
Block a user