From 0b54b163503f74986f49d07f988ebf1bd8606fc5 Mon Sep 17 00:00:00 2001 From: Robin Champenois Date: Sun, 17 Jan 2021 21:35:11 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Donne=20les=20attributes=20=C3=A0=20get=5Fu?= =?UTF-8?q?sername?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- authens/backends.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/authens/backends.py b/authens/backends.py index fb164a7..c077716 100644 --- a/authens/backends.py +++ b/authens/backends.py @@ -43,7 +43,7 @@ class ENSCASBackend: def clean_cas_login(self, cas_login): return cas_login.strip().lower() - def get_free_username(self, cas_login): + def get_free_username(self, cas_login, attributes): """Find an available username for a new user. If you override this method, make sure it returns a username that is not taken @@ -102,7 +102,7 @@ class ENSCASBackend: user = None if user is None: - username = self.get_free_username(cas_login) + username = self.get_free_username(cas_login, attributes) user = UserModel.objects.create_user(username=username, email=email) CASAccount.objects.create( user=user, entrance_year=entrance_year, cas_login=cas_login From b8acee8d30237662c801f65d3002eb8766aae249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Thu, 21 Jan 2021 22:11:41 +0100 Subject: [PATCH 2/2] Fix get_free_username tests --- authens/tests/test_backend.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/authens/tests/test_backend.py b/authens/tests/test_backend.py index a0d06b6..3c1556f 100644 --- a/authens/tests/test_backend.py +++ b/authens/tests/test_backend.py @@ -16,11 +16,11 @@ class TestCASBackend(TestCase): UserModel.objects.create(username="toto2") backend = ENSCASBackend() for _ in range(10): - username = backend.get_free_username("toto") + username = backend.get_free_username("toto", None) self.assertFalse(UserModel.objects.filter(username=username).exists()) UserModel.objects.create(username=username) for _ in range(10): - username = backend.get_free_username("tutu") + username = backend.get_free_username("tutu", None) self.assertFalse(UserModel.objects.filter(username=username).exists()) UserModel.objects.create(username=username)