diff --git a/chameleon/ChameleonOIDCAuthBackend.py b/chameleon/ChameleonOIDCAuthBackend.py index e1c61d84..3db165fa 100644 --- a/chameleon/ChameleonOIDCAuthBackend.py +++ b/chameleon/ChameleonOIDCAuthBackend.py @@ -37,10 +37,13 @@ def authenticate(self, request, **kwargs): return login def filter_users_by_claims(self, claims): - """Override to search for users by username and not email.""" + """Override to search for users by username and email.""" username = claims.get("preferred_username") if username: return self.UserModel.objects.filter(username__iexact=username) + email = claims.get("email") + if email: + return self.UserModel.objects.filter(email__iexact=email) return self.UserModel.objects.none()