Fix cloud login submit binding

This commit is contained in:
Codex 2026-05-14 19:43:12 +08:00
parent 0f4580f566
commit 56e49b27a2
3 changed files with 26 additions and 10 deletions

View File

@ -111,6 +111,11 @@ let resolveRequestId = 0;
let temporaryQueryItems = [];
let appStarted = false;
authForm?.addEventListener("submit", async (event) => {
event.preventDefault();
await submitAccessPassword();
});
for (const [platform, element] of Object.entries(urlInputs)) {
element.addEventListener("input", () => {
dirtyUrlInputs.add(platform);
@ -610,11 +615,6 @@ dutyRunNow?.addEventListener("click", () => {
runDutyNow();
});
authForm?.addEventListener("submit", async (event) => {
event.preventDefault();
await submitAccessPassword();
});
initializeApp();
document.addEventListener("hotness:programs-changed", refreshPrograms);

View File

@ -63,6 +63,11 @@ let dirtyUrlInputs = new Set();
let deferredInstallPrompt = null;
let appStarted = false;
authForm?.addEventListener("submit", async (event) => {
event.preventDefault();
await submitAccessPassword();
});
for (const [platform, element] of Object.entries(urlInputs)) {
element.addEventListener("input", () => {
dirtyUrlInputs.add(platform);
@ -176,11 +181,6 @@ window.addEventListener("appinstalled", () => {
updateInstallPrompt("installed");
});
authForm?.addEventListener("submit", async (event) => {
event.preventDefault();
await submitAccessPassword();
});
initializeApp();
async function initializeApp() {

View File

@ -29,6 +29,14 @@ test("desktop page has a password gate and sends auth token with API calls", ()
assert.match(desktopCss, /\.auth-gate/);
});
test("desktop login submit is bound before the rest of the app can fail", () => {
const authBinding = desktopJs.indexOf('authForm?.addEventListener("submit"');
const collectBinding = desktopJs.indexOf('form.addEventListener("submit"');
assert.ok(authBinding > -1, "auth submit binding should exist");
assert.ok(collectBinding > -1, "collect submit binding should exist");
assert.ok(authBinding < collectBinding, "auth binding must run before normal app bindings");
});
test("mobile page has the same password gate for cloud use", () => {
assert.match(mobileHtml, /id="auth-gate"/);
assert.match(mobileHtml, /id="auth-password"/);
@ -38,3 +46,11 @@ test("mobile page has the same password gate for cloud use", () => {
assert.match(mobileJs, /x-hotness-auth-token/i);
assert.match(mobileCss, /\.auth-gate/);
});
test("mobile login submit is bound before normal capture events", () => {
const authBinding = mobileJs.indexOf('authForm?.addEventListener("submit"');
const collectBinding = mobileJs.indexOf('form.addEventListener("submit"');
assert.ok(authBinding > -1, "auth submit binding should exist");
assert.ok(collectBinding > -1, "collect submit binding should exist");
assert.ok(authBinding < collectBinding, "auth binding must run before normal app bindings");
});