fix(subsonic): a handler without a caller answers error 50 everywhere (#8002)

Sixteen handlers answered a missing caller with error 50 "Not
authenticated"; the star, unstar and scrobble handlers answered error 0
"Unauthenticated". Middleware stops such a request first, so no app saw
it, but the next handler copied would pick one at random. requireUser
now holds the check, the same shape as /api's, at all 21 sites.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 12:44:05 -05:00
co-authored by Claude Opus 5.5
parent 0811775af6
commit cfdd6b916f
10 changed files with 32 additions and 42 deletions
+3 -6
View File
@@ -22,9 +22,8 @@ import (
// playlistId, replaces that playlist's songs (and its name, when name is
// given). It answers with the playlist, as getPlaylist does.
func (h *pickHandlers) createPlaylist(w http.ResponseWriter, r *http.Request) {
user, ok := UserFromContext(r.Context())
user, ok := requireUser(w, r)
if !ok {
WriteFail(w, r, ErrNotAuthorized, "Not authenticated")
return
}
params := r.URL.Query()
@@ -87,9 +86,8 @@ func (h *pickHandlers) createPlaylist(w http.ResponseWriter, r *http.Request) {
// songIdToAdd at the end. Each index counts the songs as getPlaylist lists
// them before this call, so the song removed is the one the app showed.
func (h *pickHandlers) updatePlaylist(w http.ResponseWriter, r *http.Request) {
user, ok := UserFromContext(r.Context())
user, ok := requireUser(w, r)
if !ok {
WriteFail(w, r, ErrNotAuthorized, "Not authenticated")
return
}
params := r.URL.Query()
@@ -166,9 +164,8 @@ func (h *pickHandlers) updatePlaylist(w http.ResponseWriter, r *http.Request) {
// deletePlaylist deletes the playlist id.
func (h *pickHandlers) deletePlaylist(w http.ResponseWriter, r *http.Request) {
user, ok := UserFromContext(r.Context())
user, ok := requireUser(w, r)
if !ok {
WriteFail(w, r, ErrNotAuthorized, "Not authenticated")
return
}
raw := r.URL.Query().Get("id")