From a3afd20f13efac8e4810dd4fd2cfde7f21433754 Mon Sep 17 00:00:00 2001 From: Alexis Gavoty Date: Sat, 6 Jul 2013 18:54:37 +0200 Subject: [PATCH] Update yunohost_user.py --- yunohost_user.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/yunohost_user.py b/yunohost_user.py index f7aa3506..d914b42e 100644 --- a/yunohost_user.py +++ b/yunohost_user.py @@ -112,17 +112,13 @@ def user_create(username, firstname, lastname, mail, password): if mail[mail.find('@')+1:] not in domain_list()['Domains']: raise YunoHostError(22, _("Domain not found : ")+ mail[mail.find('@')+1:]) - user_added = os.system('/usr/sbin/smbldap-useradd -a -A 1 -m -M "'+ mail +'" -N "'+ firstname +'" -S "'+ lastname +'" -Z "objectclass=mailAccount,maildrop='+ username +'" -p '+ username) + user_added = os.system('/usr/sbin/smbldap-useradd -a -A 1 -m -M "'+ mail +'" -N "'+ firstname +'" -S "'+ lastname +'" -Z "objectclass=mailAccount,maildrop='+ username +'" -p '+ username) + pwd_changed = os.system('echo -e \''+ password +'\n'+ password +'\' | smbldap-passwd '+ username) - if user_added == 0: - char_set = string.ascii_uppercase + string.digits - salt = ''.join(random.sample(char_set,8)) - salt = '$1$' + salt + '$' - attr_dict = {'userPassword': '{CRYPT}' + crypt.crypt(str(password), salt)} - if yldap.update('uid=' + username + ',ou=users', attr_dict): - #TODO: Send a welcome mail to user - win_msg(_("User successfully created")) - return { _("Fullname") : firstname +' '+ lastname, _("Username") : username, _("Mail") : mail } + if user_added == pwd_changed == 0: + #TODO: Send a welcome mail to user + win_msg(_("User successfully created")) + return { _("Fullname") : firstname +' '+ lastname, _("Username") : username, _("Mail") : mail } else: raise YunoHostError(169, _("An error occured during user creation"))