Skip to content

Commit

Permalink
Merge pull request #45 from Nihongo-Jouzu/44-bugcreate-user-endpoint-…
Browse files Browse the repository at this point in the history
…is-broken

fix:Register user with hashed password.
  • Loading branch information
FilippoQuattrocchi authored Sep 12, 2024
2 parents f424d84 + 467a06e commit 60013f0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ def get_users(request):
def create_user(request):
serializer = UserSerializer(data=request.data)
if serializer.is_valid():
serializer.save()
user = User.objects.create(
username=serializer.data['username'],
)
user.set_password(serializer.data['password'])
print(user)
user.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

Expand Down

0 comments on commit 60013f0

Please sign in to comment.