mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
Implementing getUser.view
This commit is contained in:
parent
4410dec0b7
commit
d217fa9d9d
45
api/user.py
Executable file
45
api/user.py
Executable file
@ -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
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user