diff --git a/freelancer-edit/index.html b/freelancer-edit/index.html index 01be887..2a3a69c 100644 --- a/freelancer-edit/index.html +++ b/freelancer-edit/index.html @@ -164,9 +164,11 @@ hashKeys: ["has", "hash"], // Wire name used OUTWARD on the GET query string. hashWireKey: "has", - // SAVE: POST with the record id — the admin path's convention (POST with an id = - // update an existing record). Match this method in the n8n workflow. - saveMethod: "POST", + // SAVE: PATCH the existing record, carrying BOTH the hash (the credential, same key + // the delete already sends) and the record id. An id alone authorises nothing: record + // ids are small sequential integers, publicly visible on every directory card, so a + // request without the hash is refused before it is sent. Match this method in n8n. + saveMethod: "PATCH", // DELETE: unverified. A route that refuses it (404/405/501) is a clear failure and // this page never reports success on a non-2xx. Match this method in the workflow. deleteMethod: "DELETE", @@ -566,12 +568,22 @@ focusTotalLine.setAttribute("data-bad", "1"); return; } + // A save is authorised by the HASH, not by the id. If this page holds no hash there + // is nothing to prove ownership, so the request is not fired at all — a PATCH + // carrying only an id is exactly the hole this closes. Say why, do not fail silently. + if (!hash) { + line.className = "status state-err"; + line.textContent = "This link arrived without its code, so we cannot save your " + + "changes. Open it again from the email that brought you here."; + return; + } save.disabled = true; line.className = "status"; line.textContent = "Saving…"; - // The body shape: the record's id + every field this form owns. SAVE_METHOD is - // C.saveMethod ("POST", the admin path's convention). - var payload = { id: rec && rec.id !== undefined ? rec.id : undefined }; + // The body shape: the credential (the SAME "has" key the delete sends, one + // credential path for both) + the record's id + every field this form owns. + // Method is C.saveMethod ("PATCH"). + var payload = { has: hash, id: rec && rec.id !== undefined ? rec.id : undefined }; payload.Name = document.getElementById("edName").value.trim(); payload.Focus = document.getElementById("edFocus").value.trim(); payload.description = document.getElementById("edDescription").value.trim();