From 9fdadaf478310dce7aa1ca2c9dbb107b7493b536 Mon Sep 17 00:00:00 2001 From: detraz Date: Sat, 8 Sep 2018 21:11:04 +0200 Subject: [PATCH] =?UTF-8?q?Le=20home=20est=20une=20methode=20+=20r=C3=A8gl?= =?UTF-8?q?e=20les=20probl=C3=A8mes=20de=20la=20casse=20sur=20le=20pseudo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/users/models.py b/users/models.py index 41090ab1..f579148c 100755 --- a/users/models.py +++ b/users/models.py @@ -93,7 +93,7 @@ from preferences.models import OptionalMachine, MailMessageOption def linux_user_check(login): """ Validation du pseudo pour respecter les contraintes unix""" - UNIX_LOGIN_PATTERN = re.compile("^[a-zA-Z0-9-]*[$]?$") + UNIX_LOGIN_PATTERN = re.compile("^[a-zA-Z][a-zA-Z0-9-]*[$]?$") return UNIX_LOGIN_PATTERN.match(login) @@ -374,6 +374,10 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser, si il n'est pas défini""" return self.shell or OptionalUser.get_cached_value('shell_default') + @cached_property + def home_directory(self): + return '/home/' + self.pseudo + @cached_property def get_shadow_expire(self): """Return the shadow_expire value for the user""" @@ -581,7 +585,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser, user_ldap.name = self.pseudo user_ldap.sn = self.pseudo user_ldap.dialupAccess = str(self.has_access()) - user_ldap.home_directory = '/home/' + self.pseudo + user_ldap.home_directory = self.home_directory user_ldap.mail = self.get_mail user_ldap.given_name = self.surname.lower() + '_'\ + self.name.lower()[:3]