Skip to content

Commit

Permalink
fix(users): user can no longer use self invite code
Browse files Browse the repository at this point in the history
  • Loading branch information
temirovazat committed Nov 16, 2023
1 parent f455058 commit 84cd683
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/api/v1/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,15 @@ def post(self, request):
{'invited_by_code': 'Неверный реферальный код.'},
status=status.HTTP_403_FORBIDDEN
)
ref_user = user.first()
if (
ref_user.phone == phone
and ref_user.invite_code.lower() == invited_by_code.lower()
):
return Response(
{'invited_by_code': 'Нельзя использовать свой код.'},
status=status.HTTP_403_FORBIDDEN
)
user_data['invited_by_code'] = invited_by_code

user, _ = User.objects.update_or_create(
Expand Down

0 comments on commit 84cd683

Please sign in to comment.