1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-23 01:16:18 +00:00

Fixed potential issue when trying to delete a user

This commit is contained in:
spl0k 2017-08-08 19:19:33 +02:00
parent 7f736c240b
commit 10ca91bd6f
2 changed files with 9 additions and 9 deletions

View File

@ -192,7 +192,7 @@ def add_user():
@app.route('/user/del/<uid>')
def del_user(uid):
status = UserManager.delete(store, uuid.UUID(uid))
status = UserManager.delete(store, uid)
if status == UserManager.SUCCESS:
flash('Deleted user')
else:

View File

@ -70,14 +70,14 @@ class UserManager:
if status != UserManager.SUCCESS:
return status
store.find(StarredFolder, StarredFolder.user_id == uid).remove()
store.find(StarredArtist, StarredArtist.user_id == uid).remove()
store.find(StarredAlbum, StarredAlbum.user_id == uid).remove()
store.find(StarredTrack, StarredTrack.user_id == uid).remove()
store.find(RatingFolder, RatingFolder.user_id == uid).remove()
store.find(RatingTrack, RatingTrack.user_id == uid).remove()
store.find(ChatMessage, ChatMessage.user_id == uid).remove()
for playlist in store.find(Playlist, Playlist.user_id == uid):
store.find(StarredFolder, StarredFolder.user_id == user.id).remove()
store.find(StarredArtist, StarredArtist.user_id == user.id).remove()
store.find(StarredAlbum, StarredAlbum.user_id == user.id).remove()
store.find(StarredTrack, StarredTrack.user_id == user.id).remove()
store.find(RatingFolder, RatingFolder.user_id == user.id).remove()
store.find(RatingTrack, RatingTrack.user_id == user.id).remove()
store.find(ChatMessage, ChatMessage.user_id == user.id).remove()
for playlist in store.find(Playlist, Playlist.user_id == user.id):
playlist.tracks.clear()
store.remove(playlist)