fix(auth): a password reset signs out Subsonic apps too, and a change can (#8107)

A reset ended every session but left the API key and Subsonic password
working, and anyone signed in to the account can make either. So whoever had
the account kept it through a Subsonic app after the owner reset the
password. The forgotten-password reset and an admin's reset now replace the
API key with one nobody holds and clear the Subsonic password.

A self-service change keeps Subsonic apps signed in by default, since it
would sign out the owner's own apps too. The web and Android password forms
gain "Sign out Subsonic apps too", sent as sign_out_subsonic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 23:48:21 -05:00
co-authored by Claude Opus 5.5
parent 1c28e17dfc
commit c6a9535cf7
16 changed files with 246 additions and 18 deletions
+7 -3
View File
@@ -276,9 +276,10 @@ func (h *handlers) handleAdminResetPassword(w http.ResponseWriter, r *http.Reque
return
}
// The target's existing sessions end with the old password. An admin
// resetting their own password keeps the session they're using, the
// same as a self-service change.
// The target's existing sessions end with the old password, and so does
// their Subsonic apps' access (signOutSubsonicApps). An admin resetting
// their own password keeps the session they're using, the same as a
// self-service change.
sessID, ownSession := auth.SessionIDFromContext(r.Context())
if targetID == caller.ID && ownSession {
_, err = q.DeleteOtherSessionsForUser(r.Context(), dbq.DeleteOtherSessionsForUserParams{UserID: targetID, ID: sessID})
@@ -288,6 +289,9 @@ func (h *handlers) handleAdminResetPassword(w http.ResponseWriter, r *http.Reque
if err != nil {
h.logger.Error("admin reset password: revoke sessions failed", "err", err)
}
if err := h.signOutSubsonicApps(r.Context(), targetID); err != nil {
h.logger.Error("admin reset password: sign out subsonic apps failed", "err", err)
}
audit.WriteOrLog(r.Context(), h.pool, h.logger, caller.ID, targetID, audit.ActionPasswordResetAdmin, nil)