Skip to content

Commit

Permalink
fix deleting password from profile data
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakser committed Oct 28, 2023
1 parent 1a0ce91 commit fc01fbc
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions partner_programs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ def post(self, request, *args, **kwargs):
data={"detail": "You need to pass an email address."},
status=status.HTTP_400_BAD_REQUEST,
)
password = data.get("password")
if not password:
return Response(
data={"detail": "You need to pass a password."},
status=status.HTTP_400_BAD_REQUEST,
)

user_fields = (
"first_name",
Expand All @@ -106,18 +112,11 @@ def post(self, request, *args, **kwargs):
status=status.HTTP_400_BAD_REQUEST,
)

password = data.get("password")
del data["password"]
if not password:
return Response(
data={"detail": "You need to pass a password."},
status=status.HTTP_400_BAD_REQUEST,
)
user.set_password(password)
user.save()

user_profile_program_data = {
k: v for k, v in data.items() if k not in user_fields
k: v for k, v in data.items() if k not in user_fields and k != "password"
}
PartnerProgramUserProfile.objects.create(
partner_program_data=user_profile_program_data,
Expand Down

0 comments on commit fc01fbc

Please sign in to comment.