diff --git a/api/user.py b/api/user.py new file mode 100755 index 0000000..947677e --- /dev/null +++ b/api/user.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +from flask import request +from web import app +from db import User + +@app.route('/rest/getUser.view') +def user_info(): + username = request.args.get('username') + if username is None: + return request.formatter({ + 'error': { + 'code': 10, + 'message': 'Missing username' + } + }, error = True) + + user = User.query.filter(User.name == username).first() + if user is None: + return request.formatter({ + 'error': { + 'code': 0, + 'message': 'Unkwown user' + } + }, error = True) + + return request.formatter({ + 'user': { + 'username': user.name, + 'email': user.mail, + 'scrobblingEnabled': False, + 'adminRole': user.admin, + 'settingsRole': False, + 'downloadRole': False, + 'uploadRole': False, + 'playlistRole': False, + 'coverArtRole': False, + 'commentRole': False, + 'podcastRole': False, + 'streamRole': False, + 'jukeboxRole': False, + 'shareRole': False + } + }) + diff --git a/web.py b/web.py index e6790f6..eaff244 100755 --- a/web.py +++ b/web.py @@ -181,4 +181,5 @@ def scan_folder(id = None): import api.system import api.browse +import api.user