Prevent overwrites from web UI (closes #12)

This commit is contained in:
Raphaël Thériault 2020-01-16 00:54:02 -05:00
parent 7dcf7c3746
commit 35ba76a28d
2 changed files with 7 additions and 4 deletions

View File

@ -318,13 +318,14 @@
(x) => x.id === parseInt(urlInput.value, 36) (x) => x.id === parseInt(urlInput.value, 36)
) )
) { ) {
urlInput.classList.add("conflict"); urlInput.setCustomValidity("ID already in use");
} else { } else {
urlInput.classList.remove("conflict"); urlInput.setCustomValidity("");
} }
submitButton.disabled = inputs[group].some( submitButton.disabled = inputs[group].some(
(input) => (input) =>
input.validity != undefined && !input.validity.valid input.validity !== undefined &&
!input.validity.valid
); );
}; };
checkValidity(); checkValidity();
@ -394,6 +395,7 @@
fetch(url, { fetch(url, {
method: "PUT", method: "PUT",
body: JSON.stringify({ forward }), body: JSON.stringify({ forward }),
headers: { "Content-Type": "application/json" },
}) })
.then((response) => { .then((response) => {
status = response.status; status = response.status;
@ -421,6 +423,7 @@
fetch(url, { fetch(url, {
method: "PUT", method: "PUT",
body: JSON.stringify({ contents, highlight }), body: JSON.stringify({ contents, highlight }),
headers: { "Content-Type": "application/json" },
}) })
.then((response) => { .then((response) => {
status = response.status; status = response.status;

View File

@ -277,7 +277,7 @@ pub fn init(init: bool) -> Config {
} }
let keep_empty = Confirmation::new() 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) .default(false)
.interact() .interact()
.unwrap_or_else(|e| { .unwrap_or_else(|e| {