Skip to content

Commit

Permalink
actually use USER_ID_FIELD in some places it wasnt used
Browse files Browse the repository at this point in the history
  • Loading branch information
obayemi committed Jul 22, 2024
1 parent 6ac7e97 commit 030ad87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions djoser/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_context_data(self):
context = super().get_context_data()

user = context.get("user")
context["uid"] = utils.encode_uid(user.pk)
context["uid"] = utils.encode_uid(getattr(user, settings.USER_ID_FIELD))
context["token"] = default_token_generator.make_token(user)
context["url"] = settings.ACTIVATION_URL.format(**context)
return context
Expand All @@ -31,7 +31,7 @@ def get_context_data(self):
context = super().get_context_data()

user = context.get("user")
context["uid"] = utils.encode_uid(user.pk)
context["uid"] = utils.encode_uid(getattr(user, settings.USER_ID_FIELD))
context["token"] = default_token_generator.make_token(user)
context["url"] = settings.PASSWORD_RESET_CONFIRM_URL.format(**context)
return context
Expand All @@ -52,7 +52,7 @@ def get_context_data(self):
context = super().get_context_data()

user = context.get("user")
context["uid"] = utils.encode_uid(user.pk)
context["uid"] = utils.encode_uid(getattr(user, settings.USER_ID_FIELD))
context["token"] = default_token_generator.make_token(user)
context["url"] = settings.USERNAME_RESET_CONFIRM_URL.format(**context)
return context
2 changes: 1 addition & 1 deletion djoser/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def validate(self, attrs):
# doesn't work with modelserializer
try:
uid = utils.decode_uid(self.initial_data.get("uid", ""))
self.user = User.objects.get(pk=uid)
self.user = User.objects.get(**{settings.USER_ID_FIELD: uid})
except (User.DoesNotExist, ValueError, TypeError, OverflowError):
key_error = "invalid_uid"
raise ValidationError(
Expand Down

0 comments on commit 030ad87

Please sign in to comment.