From 35ba76a28dc50b8acc9bf467a369751e79c33a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Th=C3=A9riault?= Date: Thu, 16 Jan 2020 00:54:02 -0500 Subject: [PATCH] Prevent overwrites from web UI (closes #12) --- resources/index.html | 9 ++++++--- src/setup.rs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/resources/index.html b/resources/index.html index b2aecd5..6c914e0 100644 --- a/resources/index.html +++ b/resources/index.html @@ -318,13 +318,14 @@ (x) => x.id === parseInt(urlInput.value, 36) ) ) { - urlInput.classList.add("conflict"); + urlInput.setCustomValidity("ID already in use"); } else { - urlInput.classList.remove("conflict"); + urlInput.setCustomValidity(""); } submitButton.disabled = inputs[group].some( (input) => - input.validity != undefined && !input.validity.valid + input.validity !== undefined && + !input.validity.valid ); }; checkValidity(); @@ -394,6 +395,7 @@ fetch(url, { method: "PUT", body: JSON.stringify({ forward }), + headers: { "Content-Type": "application/json" }, }) .then((response) => { status = response.status; @@ -421,6 +423,7 @@ fetch(url, { method: "PUT", body: JSON.stringify({ contents, highlight }), + headers: { "Content-Type": "application/json" }, }) .then((response) => { status = response.status; diff --git a/src/setup.rs b/src/setup.rs index 01c3b44..81538b7 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -277,7 +277,7 @@ pub fn init(init: bool) -> Config { } let keep_empty = Confirmation::new() - .with_text("Are you sure you want to leave an empty password? This will disable authentication") + .with_text("Are you sure you want to leave an empty password? This will disable authentication.") .default(false) .interact() .unwrap_or_else(|e| {