From f975cc2811fde05ab6d3fe44062c1a9b3463ff6d Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Thu, 21 Jan 2021 22:31:10 +0100 Subject: [PATCH] =?UTF-8?q?On=20d=C3=A9place=20la=20cr=C3=A9ation=20d'util?= =?UTF-8?q?isateurs=20dans=20une=20m=C3=A9thode=20=C3=A0=20part=20pour=20p?= =?UTF-8?q?ouvoir=20override?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- authens/backends.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/authens/backends.py b/authens/backends.py index c077716..f1f0ba8 100644 --- a/authens/backends.py +++ b/authens/backends.py @@ -73,6 +73,14 @@ class ENSCASBackend: i += 1 return radical + str(i) + def create_user(self, username, attributes): + """Create a CAS user, base method that can be overrided to add more + information. + """ + + email = attributes.get("email") + return UserModel.objects.create_user(username=username, email=email) + def _get_or_create(self, cas_login, attributes): """Handles account retrieval, creation and invalidation as described above. @@ -82,7 +90,6 @@ class ENSCASBackend: - If a matching CAS account exists, retrieve it. """ - email = attributes.get("email") entrance_year = parse_entrance_year(attributes.get("homeDirectory")) if entrance_year is None: raise ENSCASError("Entrance year not available") @@ -103,7 +110,7 @@ class ENSCASBackend: if user is None: username = self.get_free_username(cas_login, attributes) - user = UserModel.objects.create_user(username=username, email=email) + user = self.create_user(username, attributes) CASAccount.objects.create( user=user, entrance_year=entrance_year, cas_login=cas_login )