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

BaseBackend.get_user: Relax user_id param type #2121

Merged

Conversation

tony
Copy link
Contributor

@tony tony commented May 3, 2024

Loosen the user_id typing in BaseBackend.get_user()

In theory, this pk could be anything, given that AUTH_USER_MODEL can resolved to any custom model (often a AbstractBaseUser subclass.)

See also:

Related issues

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Makes sense for BaseBackend: uuid, str, ObjectID, etc

@sobolevn sobolevn merged commit 9b6c3b3 into typeddjango:master May 3, 2024
40 checks passed
@tony tony deleted the auth-backend-get-user-id-param-type branch May 3, 2024 23:03
@@ -13,7 +13,7 @@ UserModel: Any

class BaseBackend:
def authenticate(self, request: HttpRequest | None, **kwargs: Any) -> AbstractBaseUser | None: ...
def get_user(self, user_id: int) -> AbstractBaseUser | None: ...
def get_user(self, user_id: Any) -> AbstractBaseUser | None: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

Personally I would have preferred int | str | UUID. But OK, let's keep this for now

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

Successfully merging this pull request may close these issues.

django.contrib.auth.BaseBackend.get_user(): user_id is too strict
3 participants