mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
Porting supysonic.api.user
This commit is contained in:
parent
42283817fe
commit
153c5f42ba
@ -1,7 +1,7 @@
|
|||||||
# This file is part of Supysonic.
|
# This file is part of Supysonic.
|
||||||
# Supysonic is a Python implementation of the Subsonic server API.
|
# Supysonic is a Python implementation of the Subsonic server API.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2013-2020 Alban 'spl0k' Féron
|
# Copyright (C) 2013-2022 Alban 'spl0k' Féron
|
||||||
#
|
#
|
||||||
# Distributed under terms of the GNU AGPLv3 license.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ from ..db import User
|
|||||||
from ..managers.user import UserManager
|
from ..managers.user import UserManager
|
||||||
|
|
||||||
from . import decode_password, api_routing
|
from . import decode_password, api_routing
|
||||||
from .exceptions import Forbidden, NotFound
|
from .exceptions import Forbidden
|
||||||
|
|
||||||
|
|
||||||
def admin_only(f):
|
def admin_only(f):
|
||||||
@ -33,9 +33,6 @@ def user_info():
|
|||||||
raise Forbidden()
|
raise Forbidden()
|
||||||
|
|
||||||
user = User.get(name=username)
|
user = User.get(name=username)
|
||||||
if user is None:
|
|
||||||
raise NotFound("User")
|
|
||||||
|
|
||||||
return request.formatter("user", user.as_subsonic_user())
|
return request.formatter("user", user.as_subsonic_user())
|
||||||
|
|
||||||
|
|
||||||
@ -99,8 +96,6 @@ def user_changepass():
|
|||||||
def user_edit():
|
def user_edit():
|
||||||
username = request.values["username"]
|
username = request.values["username"]
|
||||||
user = User.get(name=username)
|
user = User.get(name=username)
|
||||||
if user is None:
|
|
||||||
raise NotFound("User")
|
|
||||||
|
|
||||||
if "password" in request.values:
|
if "password" in request.values:
|
||||||
password = decode_password(request.values["password"])
|
password = decode_password(request.values["password"])
|
||||||
@ -120,4 +115,6 @@ def user_edit():
|
|||||||
jukebox = jukebox in (True, "True", "true", 1, "1")
|
jukebox = jukebox in (True, "True", "true", 1, "1")
|
||||||
user.jukebox = jukebox
|
user.jukebox = jukebox
|
||||||
|
|
||||||
|
user.save()
|
||||||
|
|
||||||
return request.formatter.empty
|
return request.formatter.empty
|
||||||
|
@ -401,7 +401,7 @@ class User(_Model):
|
|||||||
def as_subsonic_user(self):
|
def as_subsonic_user(self):
|
||||||
return {
|
return {
|
||||||
"username": self.name,
|
"username": self.name,
|
||||||
"email": self.mail,
|
"email": self.mail or "",
|
||||||
"scrobblingEnabled": self.lastfm_session is not None and self.lastfm_status,
|
"scrobblingEnabled": self.lastfm_session is not None and self.lastfm_status,
|
||||||
"adminRole": self.admin,
|
"adminRole": self.admin,
|
||||||
"settingsRole": True,
|
"settingsRole": True,
|
||||||
|
Loading…
Reference in New Issue
Block a user