Hotfix: JSON parse on POST method

This commit is contained in:
Marcin Armacki 2020-11-08 21:20:13 +01:00
parent 4c6a6cc73f
commit 258d0f33ae

View File

@ -77,7 +77,8 @@ def visualize(request, id):
@csrf_exempt
def user(request):
if request.method == 'POST':
result = registerNewUser(request.POST["email"], request.POST["password"])
data = json.loads(request.body.decode("utf-8"))
result = registerNewUser(data["email"], data["password"])
return JsonResponse(result, status = result["statusCode"])
else:
return JsonResponse(MethodNotAllowed, status = MethodNotAllowed["statusCode"])
@ -85,7 +86,8 @@ def user(request):
@csrf_exempt
def login(request):
if request.method == 'POST':
result = loginUser(request.POST["email"], request.POST["password"])
data = json.loads(request.body.decode("utf-8"))
result = loginUser(data["email"], data["password"])
return JsonResponse(result, status = result["statusCode"])
else:
return JsonResponse(MethodNotAllowed, status = MethodNotAllowed["statusCode"])