diff --git a/.readthedocs.yml b/.readthedocs.yml index 95a27809..2646802c 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,5 +1,9 @@ --- version: 2 +build: + os: ubuntu-lts-latest + tools: + python: "3.12" python: install: - requirements: docs/requirements.txt diff --git a/django_auth_ldap/backend.py b/django_auth_ldap/backend.py index fc37ef23..17c5e0c9 100644 --- a/django_auth_ldap/backend.py +++ b/django_auth_ldap/backend.py @@ -140,6 +140,7 @@ def get_user_model(self): # def authenticate(self, request, username=None, password=None, **kwargs): + username = kwargs.get(self.get_user_model().USERNAME_FIELD, username) if username is None: return None diff --git a/tests/tests.py b/tests/tests.py index 326bcabc..79646833 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -274,6 +274,17 @@ def test_deepcopy(self): user = authenticate(username="Alice", password="password") user = deepcopy(user) + @_override_settings(AUTH_USER_MODEL="tests.TestUser") + def test_auth_custom_field(self): + self._init_settings( + USER_DN_TEMPLATE="cn=%(user)s,ou=people,o=test", + USER_ATTR_MAP={"identifier": "cn"}, + ) + charlie = TestUser.objects.create(identifier="charlie_cooper", uid_number=1004) + user = authenticate(identifier="charlie_cooper", password="password") + self.assertIsInstance(user, TestUser) + self.assertEqual(user.identifier, charlie.identifier) + @_override_settings(AUTH_USER_MODEL="tests.TestUser") def test_auth_custom_user(self): self._init_settings(
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: