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
+8 -1
View File
@@ -35,10 +35,17 @@ export type MyProfile = {
export type APITokenResponse = { api_token: string };
export async function changePassword(currentPassword: string, newPassword: string): Promise<void> {
// signOutSubsonic also ends every Subsonic app's access (the API token and
// the Subsonic password stop working), for a password someone else may know.
export async function changePassword(
currentPassword: string,
newPassword: string,
signOutSubsonic = false,
): Promise<void> {
await api.put('/api/me/password', {
current_password: currentPassword,
new_password: newPassword,
sign_out_subsonic: signOutSubsonic,
});
}
+20 -2
View File
@@ -78,6 +78,7 @@
let current = $state('');
let next = $state('');
let confirm = $state('');
let signOutSubsonic = $state(false);
let passwordSaving = $state(false);
async function onSavePassword(e: SubmitEvent) {
@@ -88,9 +89,14 @@
}
passwordSaving = true;
try {
await changePassword(current, next);
pushToast('Password changed. Your other devices have been signed out.');
await changePassword(current, next, signOutSubsonic);
pushToast(
signOutSubsonic
? 'Password changed. Your other devices and Subsonic apps have been signed out.'
: 'Password changed. Your other devices have been signed out.',
);
current = next = confirm = '';
signOutSubsonic = false;
} catch (err: unknown) {
const code = errCode(err);
if (code === 'wrong_password') pushToast('Current password is incorrect.', 'error');
@@ -183,6 +189,18 @@
class={input}
/>
</SettingRow>
<SettingRow
label="Sign out Subsonic apps too"
hint="Your API token and Subsonic password stop working."
for="password-signout-subsonic"
>
<input
id="password-signout-subsonic"
type="checkbox"
bind:checked={signOutSubsonic}
class="h-4 w-4 cursor-pointer accent-accent"
/>
</SettingRow>
<div class="flex justify-end px-4 py-3">
<button type="submit" disabled={passwordSaving || !current || !next || !confirm} class={primary}>
{passwordSaving ? 'Saving…' : 'Change password'}
@@ -78,7 +78,21 @@ describe('Settings › Account', () => {
await fireEvent.input(screen.getByLabelText(/^new password/i), { target: { value: 'newpw1234' } });
await fireEvent.input(screen.getByLabelText(/confirm new password/i), { target: { value: 'newpw1234' } });
await fireEvent.click(screen.getByRole('button', { name: /change password/i }));
await waitFor(() => expect(changePassword).toHaveBeenCalledWith('oldpw1234', 'newpw1234'));
await waitFor(() => expect(changePassword).toHaveBeenCalledWith('oldpw1234', 'newpw1234', false));
});
test('ticking "Sign out Subsonic apps too" asks the server to sign them out', async () => {
setup();
vi.mocked(changePassword).mockResolvedValue(undefined);
await fireEvent.input(screen.getByLabelText(/current password/i), { target: { value: 'oldpw1234' } });
await fireEvent.input(screen.getByLabelText(/^new password/i), { target: { value: 'newpw1234' } });
await fireEvent.input(screen.getByLabelText(/confirm new password/i), { target: { value: 'newpw1234' } });
await fireEvent.click(screen.getByLabelText(/sign out subsonic apps too/i));
await fireEvent.click(screen.getByRole('button', { name: /change password/i }));
await waitFor(() => expect(changePassword).toHaveBeenCalledWith('oldpw1234', 'newpw1234', true));
expect(pushToast).toHaveBeenCalledWith(
'Password changed. Your other devices and Subsonic apps have been signed out.',
);
});
test('the Android app leads the page when the server bundles it', async () => {