fix(web): keep generated passwords out of page source

This commit is contained in:
2026-07-17 07:04:46 +08:00
parent e8605f15a2
commit d1e4068636
8 changed files with 44 additions and 11 deletions
+8
View File
@@ -36,3 +36,11 @@ document.addEventListener("click", async function (event) {
// The downloadable JSON link remains available when clipboard access is unavailable.
}
});
const oneTimeSecret = document.querySelector("[data-one-time-secret-url]");
if (oneTimeSecret) {
fetch(oneTimeSecret.dataset.oneTimeSecretUrl, { method: "POST", credentials: "same-origin", headers: { "X-CSRF-Token": oneTimeSecret.dataset.csrfToken } })
.then(async function (response) { if (!response.ok) throw new Error("one-time secret unavailable"); return response.json(); })
.then(function (data) { oneTimeSecret.querySelector(".one-time-secret").textContent = data.password; })
.catch(function () { oneTimeSecret.querySelector(".one-time-secret").textContent = "—"; });
}