feat(sync): paginate Android sync with change tokens
Lint / Lint (push) Successful in 1m8s
Tests / Go backend (push) Failing after 1m23s
Tests / Dashboard checks (push) Failing after 38s
Docker / Docker Build & Push (push) Failing after 6m29s

This commit is contained in:
Gabriel20xx committed 2026-10-20 15:27:53 +00:00
1 parent 0ff94f9b10
commit 97c237be80
76 files changed
+3401 -851

No files matched your search

+5 -4
View File
@@ -120,12 +120,13 @@ export async function logout() {
// always be the account's current values when the caller isn't actually
// changing them. ProfileDialog's form (@gabriel20xx/web-ui) always pre-fills
// and requires both fields, so AppShell.svelte's saveProfile always has them
// on hand. newPassword remains genuinely optional (omitted/blank leaves the
// password unchanged).
export async function updateCredentials({ newUsername, newEmail, newPassword }) {
// on hand. When changing the password, the shared ProfileDialog also supplies
// currentPassword and (when enabled) totpToken for sharedauth's reauthentication
// check. newPassword remains optional when it is not being changed.
export async function updateCredentials({ newUsername, newEmail, newPassword, currentPassword, totpToken }) {
return request('/api/auth/credentials', {
method: 'POST',
body: JSON.stringify({ username: newUsername, email: newEmail, password: newPassword }),
body: JSON.stringify({ username: newUsername, email: newEmail, password: newPassword, currentPassword, totpToken }),
});
}
+53
View File
@@ -0,0 +1,53 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
import { updateCredentials } from './api.js';
test('updateCredentials forwards current password and TOTP proof', async () => {
const originalFetch = globalThis.fetch;
let captured;
globalThis.fetch = async (url, options) => {
captured = { url, options };
return { ok: true, status: 200, json: async () => ({}) };
};
try {
await updateCredentials({
newUsername: 'owner',
newEmail: 'owner@example.com',
newPassword: 'new-password',
currentPassword: 'current-password',
totpToken: '123456',
});
assert.equal(captured.url, '/api/auth/credentials');
assert.deepEqual(JSON.parse(captured.options.body), {
username: 'owner',
email: 'owner@example.com',
password: 'new-password',
currentPassword: 'current-password',
totpToken: '123456',
});
} finally {
globalThis.fetch = originalFetch;
}
});
test('updateCredentials omits reauthentication proof when password is unchanged', async () => {
const originalFetch = globalThis.fetch;
let captured;
globalThis.fetch = async (_url, options) => {
captured = options;
return { ok: true, status: 200, json: async () => ({}) };
};
try {
await updateCredentials({ newUsername: 'owner', newEmail: 'owner@example.com' });
assert.deepEqual(JSON.parse(captured.body), {
username: 'owner',
email: 'owner@example.com',
});
} finally {
globalThis.fetch = originalFetch;
}
});
@@ -30,6 +30,8 @@
newUsername: input.username.trim(),
newEmail: input.email.trim(),
newPassword: input.password || undefined,
currentPassword: input.currentPassword,
totpToken: input.totpToken,
});
}
</script>