diff --git a/authens/models.py b/authens/models.py index a1cbd25..b68b7d0 100644 --- a/authens/models.py +++ b/authens/models.py @@ -30,6 +30,9 @@ class CASAccount(models.Model): verbose_name=_("année de création du compte CAS"), blank=False, null=False ) + # The entrance year 0 is used for members of staff + STAFF_ENTRANCE_YEAR = 0 + class Meta: verbose_name = _("Compte CAS") verbose_name_plural = _("Comptes CAS") diff --git a/authens/utils.py b/authens/utils.py index 733cf10..7306506 100644 --- a/authens/utils.py +++ b/authens/utils.py @@ -6,6 +6,7 @@ from cas import CASClient from django.conf import settings from authens import conf as default_conf +from authens.models import CASAccount def get_cas_client(request): @@ -35,9 +36,8 @@ def parse_entrance_year(home_dir): settings, "AUTHENS_ALLOW_STAFF", default_conf.AUTHENS_ALLOW_STAFF ) - # The staff members have an entrance year set to 0 if allow_staff and dirs[:3] == ["", "users", "staffs"]: - return 0 + return CASAccount.STAFF_ENTRANCE_YEAR if len(dirs) < 3 or not dirs[2].isdecimal() or dirs[1] != "users": raise ValueError("Invalid home directory: {}".format(home_dir))