mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Correct PUT method handling & Add infos to user_info
This commit is contained in:
parent
badc24cb98
commit
5c7f66eb3c
2 changed files with 10 additions and 5 deletions
11
yunohost.tac
11
yunohost.tac
|
@ -8,9 +8,9 @@ import json
|
|||
|
||||
sys.path.append('/usr/share/pyshared')
|
||||
|
||||
from twisted.python.log import ILogObserver, FileLogObserver, startLogging
|
||||
from twisted.python.log import ILogObserver, FileLogObserver, startLogging, msg
|
||||
from twisted.python.logfile import DailyLogFile
|
||||
from twisted.web.server import Site
|
||||
from twisted.web.server import Site, http
|
||||
from twisted.internet import reactor
|
||||
from twisted.application import internet,service
|
||||
from txrestapi.resource import APIResource
|
||||
|
@ -56,14 +56,17 @@ def http_exec(request, **kwargs):
|
|||
return 'Unauthorized'
|
||||
|
||||
path = request.path
|
||||
given_args = request.args
|
||||
if request.method == 'PUT':
|
||||
given_args = http.parse_qs(request.content.read(), 1)
|
||||
else:
|
||||
given_args = request.args
|
||||
if kwargs:
|
||||
for k, v in kwargs.iteritems():
|
||||
dynamic_key = path.split('/')[-1]
|
||||
path = path.replace(dynamic_key, '{'+ k +'}')
|
||||
given_args[k] = [v]
|
||||
|
||||
print given_args
|
||||
msg(given_args)
|
||||
# Sanitize arguments
|
||||
dict = action_dict[request.method +' '+ path]
|
||||
if 'arguments' in dict: possible_args = dict['arguments']
|
||||
|
|
|
@ -260,7 +260,7 @@ def user_info(username):
|
|||
|
||||
"""
|
||||
with YunoHostLDAP() as yldap:
|
||||
user_attrs = ['cn', 'mail', 'uid', 'maildrop']
|
||||
user_attrs = ['cn', 'mail', 'uid', 'maildrop', 'givenName', 'sn']
|
||||
|
||||
if len(username.split('@')) is 2:
|
||||
filter = 'mail='+ username
|
||||
|
@ -277,6 +277,8 @@ def user_info(username):
|
|||
result_dict = {
|
||||
'Username': user['uid'][0],
|
||||
'Fullname': user['cn'][0],
|
||||
'Firstname': user['givenName'][0],
|
||||
'Lastname': user['sn'][0],
|
||||
'Mail': user['mail'][0]
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue