Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actually use USER_ID_FIELD in some places it wasnt used #789

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ This project adheres to `Semantic Versioning <http://semver.org/>`_.
`0.7.0`_ (2017-09-01)
---------------------

* Add ``TOKEN_MODEL`` setting to allow third party apps to specify a custom token model
* Add ``TOKEN_MODEL`` setting to allow third party apps to specify a custom token modelclosed
* Add ``USER_EMAIL_FIELD_NAME`` setting as a compatibility solution in Django < 1.11
* Add support for Django Password Validators
* Add HTML templates for djoser emails
Expand Down
6 changes: 3 additions & 3 deletions djoser/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,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 @@ -135,7 +135,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 @@ -156,7 +156,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 @@ -175,7 +175,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