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

models: make sure uid is compared case-sensitive #566

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions social_django/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,15 @@ class Meta:
abstract = True

@classmethod
def get_social_auth(cls, provider, uid):
try:
return cls.objects.select_related("user").get(provider=provider, uid=uid)
except cls.DoesNotExist:
return None
def get_social_auth(cls, provider: str, uid: str):
for social in cls.objects.select_related("user").filter(
provider=provider, uid=uid
):
# We need to compare to filter out case-insensitive lookups in
# some databases (MySQL/MariaDB)
if social.uid == uid:
return social
return None

@classmethod
def username_max_length(cls):
Expand Down