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]