Skip to content

Conversation

@Andrew-Chen-Wang
Copy link
Member

fixes #903

@Andrew-Chen-Wang Andrew-Chen-Wang requested a review from a team January 14, 2026 07:49
}
)

def get_user_queryset(self, user_id: Any = None) -> AuthUser | None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a bit nitty, but would the better method name here be get_user_object?

It would immediately be clear from the name that an object is fetched, and not a queryset, and it would be similar to DRF method: https://www.django-rest-framework.org/api-guide/generic-views/#get_objectself

Comment on lines +139 to +140
user = self.get_user_queryset(user_id)
if not user:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRF has a get_object method but they never check if really only one object is returned from the method, so i guess we shouldn't too. Just wanted to raise this so that we are aware of this problem if someone does a filter instead of get in get_user_queryset

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be ensuring that only a single object is returned, otherwise we can raise a dev internal error for multiple objects returned or an iterable is returned as a helpful guide.

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.

Provide an override-able get_queryset in JWTAuthentication

2 participants