1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-10 04:02:17 +00:00

Porting supysonic.api.user

This commit is contained in:
Alban Féron 2022-12-30 16:55:20 +01:00
parent 42283817fe
commit 153c5f42ba
No known key found for this signature in database
GPG Key ID: 8CE0313646D16165
2 changed files with 5 additions and 8 deletions

View File

@ -1,7 +1,7 @@
# This file is part of Supysonic.
# 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.
@ -12,7 +12,7 @@ from ..db import User
from ..managers.user import UserManager
from . import decode_password, api_routing
from .exceptions import Forbidden, NotFound
from .exceptions import Forbidden
def admin_only(f):
@ -33,9 +33,6 @@ def user_info():
raise Forbidden()
user = User.get(name=username)
if user is None:
raise NotFound("User")
return request.formatter("user", user.as_subsonic_user())
@ -99,8 +96,6 @@ def user_changepass():
def user_edit():
username = request.values["username"]
user = User.get(name=username)
if user is None:
raise NotFound("User")
if "password" in request.values:
password = decode_password(request.values["password"])
@ -120,4 +115,6 @@ def user_edit():
jukebox = jukebox in (True, "True", "true", 1, "1")
user.jukebox = jukebox
user.save()
return request.formatter.empty

View File

@ -401,7 +401,7 @@ class User(_Model):
def as_subsonic_user(self):
return {
"username": self.name,
"email": self.mail,
"email": self.mail or "",
"scrobblingEnabled": self.lastfm_session is not None and self.lastfm_status,
"adminRole": self.admin,
"settingsRole": True,