Skip to content

Commit

Permalink
Merge pull request #2039 from MIT-LCP/username-type-error
Browse files Browse the repository at this point in the history
Fix server error if username is none
  • Loading branch information
tompollard authored Jul 5, 2023
2 parents 6f3b623 + f5dbf5a commit 303edbb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions physionet-django/user/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class DualAuthModelBackend(ModelBackend):
This is a ModelBacked that allows authentication with either a username or an email address.
"""
def authenticate(self, request, username=None, password=None):
# After implementation of OAuth2, (presumably) many crawlers started to attempt
# authentication with tokens, causing server errors due to the comparison below.
if username is None:
return None
if '@' in username:
kwargs = {'email': username.lower()}
else:
Expand Down

0 comments on commit 303edbb

Please sign in to comment.