On déplace la création d'utilisateurs dans une méthode à part pour pouvoir override
This commit is contained in:
parent
ef08eab248
commit
f975cc2811
1 changed files with 9 additions and 2 deletions
|
@ -73,6 +73,14 @@ class ENSCASBackend:
|
||||||
i += 1
|
i += 1
|
||||||
return radical + str(i)
|
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):
|
def _get_or_create(self, cas_login, attributes):
|
||||||
"""Handles account retrieval, creation and invalidation as described above.
|
"""Handles account retrieval, creation and invalidation as described above.
|
||||||
|
|
||||||
|
@ -82,7 +90,6 @@ class ENSCASBackend:
|
||||||
- If a matching CAS account exists, retrieve it.
|
- If a matching CAS account exists, retrieve it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
email = attributes.get("email")
|
|
||||||
entrance_year = parse_entrance_year(attributes.get("homeDirectory"))
|
entrance_year = parse_entrance_year(attributes.get("homeDirectory"))
|
||||||
if entrance_year is None:
|
if entrance_year is None:
|
||||||
raise ENSCASError("Entrance year not available")
|
raise ENSCASError("Entrance year not available")
|
||||||
|
@ -103,7 +110,7 @@ class ENSCASBackend:
|
||||||
|
|
||||||
if user is None:
|
if user is None:
|
||||||
username = self.get_free_username(cas_login, attributes)
|
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(
|
CASAccount.objects.create(
|
||||||
user=user, entrance_year=entrance_year, cas_login=cas_login
|
user=user, entrance_year=entrance_year, cas_login=cas_login
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue