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

fix: Fixes issue with JWTStatelessUserAuthentication #574

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

viglia
Copy link

@viglia viglia commented Dec 5, 2023

The JWTStatelessUserAuthentication backend’s authenticate method does not perform a database lookup to obtain a user instance.

Instead, it returns a rest_framework_simplejwt.models.TokenUser instance which acts as a stateless user object backed only by a validated token instead of a record in a database.

This is not taken into account in the user and password endpoints of dj-rest-auth causing either incomplete information to be returned for the user or, in the worst case, a full crash due to invocation of methods that are not implemented for TokenUser.

This PR fixes it by checking whether the current user is a TokenUser and fetching the proper User before applying any changes.

The JWTStatelessUserAuthentication backend’s authenticate method does not perform a database lookup to obtain a user instance.

Instead, it returns a rest_framework_simplejwt.models.TokenUser instance which acts as a stateless user object backed only by a validated token instead of a record in a database.

This is not taken into account in the user and password endpoints of dj-rest-auth causing either incomplete information to be returned for the user or (in the worst case) a full crash due to invocation of methods that are not defined for TokenUser.

This PR fixes it by checking whether the current user is a TokenUser and fetch the proper User before applying any changes.
@viglia
Copy link
Author

viglia commented Dec 5, 2023

@iMerica if this gets approved/merged, could you make a patch release please?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant