Skip to content

Commit

Permalink
updated /add_user endpoint to return status code instead of user ob…
Browse files Browse the repository at this point in the history
…ject (#718)

* Update `/add_user` endpoint to return status code instead of user object
Fixes #707

* removed unessary unique username validation
  • Loading branch information
sainak authored Jun 6, 2022
1 parent 97cd891 commit fcbc9cc
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions care/users/api/viewsets/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,8 @@ def add_user(self, request, *args, **kwargs):
data={**request.data, "password": password}, context={"created_by": request.user},
)
serializer.is_valid(raise_exception=True)
username = request.data["username"]
if User.objects.filter(username=username).exists():
raise ValidationError({"username": "User with Given Username Already Exists"})
user = serializer.create(serializer.validated_data)

response_data = UserCreateSerializer(user).data
# response_data["password"] = password
return Response(data=response_data, status=status.HTTP_201_CREATED)
serializer.save()
return Response(status=status.HTTP_201_CREATED)

def has_facility_permission(self, user, facility):
return (
Expand Down

0 comments on commit fcbc9cc

Please sign in to comment.