mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Some fixes and import changes in yunohost.user
This commit is contained in:
parent
8be16b85fa
commit
f567d1d03e
1 changed files with 10 additions and 6 deletions
|
@ -28,10 +28,8 @@ import sys
|
||||||
import crypt
|
import crypt
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
from moulinette.core import MoulinetteError
|
|
||||||
|
|
||||||
from yunohost.domain import domain_list
|
from moulinette.core import MoulinetteError
|
||||||
from yunohost.hook import hook_callback
|
|
||||||
|
|
||||||
|
|
||||||
def user_list(auth, fields=None, filter=None, limit=None, offset=None):
|
def user_list(auth, fields=None, filter=None, limit=None, offset=None):
|
||||||
|
@ -60,8 +58,9 @@ def user_list(auth, fields=None, filter=None, limit=None, offset=None):
|
||||||
if filter is None:
|
if filter is None:
|
||||||
filter = '(&(objectclass=person)(!(uid=root))(!(uid=nobody)))'
|
filter = '(&(objectclass=person)(!(uid=root))(!(uid=nobody)))'
|
||||||
if fields:
|
if fields:
|
||||||
for attr in user_attrs.keys():
|
keys = user_attrs.keys()
|
||||||
if attr in fields:
|
for attr in fields:
|
||||||
|
if attr in keys:
|
||||||
attrs.append(attr)
|
attrs.append(attr)
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(22, _("Invalid field '%s'") % attr)
|
raise MoulinetteError(22, _("Invalid field '%s'") % attr)
|
||||||
|
@ -94,6 +93,9 @@ def user_create(auth, username, firstname, lastname, mail, password):
|
||||||
password
|
password
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from yunohost.domain import domain_list
|
||||||
|
from yunohost.hook import hook_callback
|
||||||
|
|
||||||
# Validate password length
|
# Validate password length
|
||||||
if len(password) < 4:
|
if len(password) < 4:
|
||||||
raise MoulinetteError(22, _("Password is too short"))
|
raise MoulinetteError(22, _("Password is too short"))
|
||||||
|
@ -193,6 +195,8 @@ def user_update(auth, username, firstname=None, lastname=None, mail=None, change
|
||||||
remove_mailalias -- Mail aliases to remove
|
remove_mailalias -- Mail aliases to remove
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from yunohost.domain import domain_list
|
||||||
|
|
||||||
attrs_to_fetch = ['givenName', 'sn', 'mail', 'maildrop']
|
attrs_to_fetch = ['givenName', 'sn', 'mail', 'maildrop']
|
||||||
new_attr_dict = {}
|
new_attr_dict = {}
|
||||||
domains = domain_list()['Domains']
|
domains = domain_list()['Domains']
|
||||||
|
@ -269,7 +273,7 @@ def user_update(auth, username, firstname=None, lastname=None, mail=None, change
|
||||||
|
|
||||||
if auth.update('uid=' + username + ',ou=users', new_attr_dict):
|
if auth.update('uid=' + username + ',ou=users', new_attr_dict):
|
||||||
msignals.display(_("User '%s' successfully updated.") % username, 'success')
|
msignals.display(_("User '%s' successfully updated.") % username, 'success')
|
||||||
return user_info(username)
|
return user_info(auth, username)
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(169, _("An error occurred during user update"))
|
raise MoulinetteError(169, _("An error occurred during user update"))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue