From 91fc7703df65e6146a651f41ab7191c0687c39a2 Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Tue, 27 Feb 2024 17:04:31 +0000 Subject: [PATCH 01/12] Made all paths relative --- static/css/style.css | 2 +- static/js/login.js | 12 ++++++------ static/js/main.js | 34 +++++++++++++++++----------------- static/js/signup.js | 8 ++++---- templates/app.html | 16 ++++++++-------- templates/error.html | 2 +- templates/login.html | 8 ++++---- templates/logout.html | 2 +- templates/main.html | 8 ++++---- templates/privacy.html | 2 +- templates/signup.html | 10 +++++----- 11 files changed, 52 insertions(+), 52 deletions(-) diff --git a/static/css/style.css b/static/css/style.css index 967baab..5d40e2a 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -1,4 +1,4 @@ -@import url("/static/fonts/inter.css"); +@import url("../fonts/inter.css"); :root { --invertdm: 0%; diff --git a/static/js/login.js b/static/js/login.js index 399a067..7800374 100644 --- a/static/js/login.js +++ b/static/js/login.js @@ -1,10 +1,10 @@ if (localStorage.getItem("DONOTSHARE-secretkey") !== null) { - window.location.replace("/app") + window.location.replace("../app/index.html") document.body.innerHTML = "Redirecting..." throw new Error(); } if (localStorage.getItem("DONOTSHARE-password") !== null) { - window.location.replace("/app") + window.location.replace("../app/index.html") document.body.innerHTML = "Redirecting..." throw new Error(); } @@ -109,7 +109,7 @@ signupButton.addEventListener("click", (event) => { return key }; - fetch("/api/login", { + fetch("https://notes.hectabit.org/api/login", { method: "POST", body: JSON.stringify({ username: username, @@ -129,11 +129,11 @@ signupButton.addEventListener("click", (event) => { localStorage.setItem("DONOTSHARE-secretkey", responseData["key"]) localStorage.setItem("DONOTSHARE-password", await hashwasm.sha512(password)) - window.location.href = "/app" + window.location.href = "../app/index.html" } else if (response.status == 401) { console.log("Trying oldhash") - fetch("/api/login", { + fetch("https://notes.hectabit.org/api/login", { method: "POST", body: JSON.stringify({ username: username, @@ -153,7 +153,7 @@ signupButton.addEventListener("click", (event) => { localStorage.setItem("DONOTSHARE-secretkey", responseData["key"]) localStorage.setItem("DONOTSHARE-password", await hashwasm.sha512(password)) - window.location.href = "/app" + window.location.href = "../app/index.html" } else if (response.status == 401) { statusBox.innerText = "Wrong username or password..." diff --git a/static/js/main.js b/static/js/main.js index f0e828c..b2fed72 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -1,10 +1,10 @@ if (localStorage.getItem("DONOTSHARE-secretkey") === null) { - window.location.replace("/login") + window.location.replace("../login/index.html") document.body.innerHTML = "Redirecting..." throw new Error(); } if (localStorage.getItem("DONOTSHARE-password") === null) { - window.location.replace("/login") + window.location.replace("../login/index.html") document.body.innerHTML = "Redirecting..." throw new Error(); } @@ -197,7 +197,7 @@ textMinusBox.addEventListener("click", (event) => { function updateUserInfo() { - fetch("/api/userinfo", { + fetch("https://notes.hectabit.org/api/userinfo", { method: "POST", body: JSON.stringify({ secretKey: secretkey @@ -214,7 +214,7 @@ function updateUserInfo() { closeErrorButton.classList.add("hidden") usernameBox.innerText = "" setTimeout(function () { - window.location.replace("/api/logout") + window.location.replace("https://notes.hectabit.org/api/logout") }, 2500); } else { let responseData = await response.json() @@ -236,7 +236,7 @@ usernameBox.addEventListener("click", (event) => { updateUserInfo() }); logOutButton.addEventListener("click", (event) => { - window.location.replace("/api/logout") + window.location.replace("https://notes.hectabit.org/api/logout") }); exitThing.addEventListener("click", (event) => { optionsDiv.classList.add("hidden") @@ -244,7 +244,7 @@ exitThing.addEventListener("click", (event) => { }); deleteMyAccountButton.addEventListener("click", (event) => { if (confirm("Are you REALLY sure that you want to delete your account? There's no going back!") == true) { - fetch("/api/deleteaccount", { + fetch("https://notes.hectabit.org/api/deleteaccount", { method: "POST", body: JSON.stringify({ secretKey: secretkey @@ -256,7 +256,7 @@ deleteMyAccountButton.addEventListener("click", (event) => { .then((response) => response) .then((response) => { if (response.status == 200) { - window.location.href = "/api/logout" + window.location.href = "https://notes.hectabit.org/api/logout" } else { displayError("Failed to delete account (HTTP error code " + response.status + ")") } @@ -267,7 +267,7 @@ sessionManagerButton.addEventListener("click", (event) => { optionsDiv.classList.add("hidden") sessionManagerDiv.classList.remove("hidden") - fetch("/api/sessions/list", { + fetch("https://notes.hectabit.org/api/sessions/list", { method: "POST", body: JSON.stringify({ secretKey: secretkey @@ -307,7 +307,7 @@ sessionManagerButton.addEventListener("click", (event) => { } sessionRemoveButton.addEventListener("click", (event) => { - fetch("/api/sessions/remove", { + fetch("https://notes.hectabit.org/api/sessions/remove", { method: "POST", body: JSON.stringify({ secretKey: secretkey, @@ -320,7 +320,7 @@ sessionManagerButton.addEventListener("click", (event) => { .then((response) => response) .then((response) => { if (responseData[i]["thisSession"] == true) { - window.location.replace("/api/logout") + window.location.replace("https://notes.hectabit.org/api/logout") } }); sessionElement.remove() @@ -358,7 +358,7 @@ function selectNote(nameithink) { let thingArray = Array.from(document.querySelectorAll(".noteButton")).find(el => el.id == nameithink); thingArray.classList.add("selected") - fetch("/api/readnote", { + fetch("https://notes.hectabit.org/api/readnote", { method: "POST", body: JSON.stringify({ secretKey: secretkey, @@ -396,7 +396,7 @@ function selectNote(nameithink) { let encryptedText = CryptoJS.AES.encrypt(noteBox.value, password).toString(); if (selectedNote == nameithink) { - fetch("/api/editnote", { + fetch("https://notes.hectabit.org/api/editnote", { method: "POST", body: JSON.stringify({ secretKey: secretkey, @@ -425,7 +425,7 @@ function selectNote(nameithink) { } function updateNotes() { - fetch("/api/listnotes", { + fetch("https://notes.hectabit.org/api/listnotes", { method: "POST", body: JSON.stringify({ secretKey: secretkey @@ -459,7 +459,7 @@ function updateNotes() { noteButton.addEventListener("click", (event) => { if (event.ctrlKey) { - fetch("/api/removenote", { + fetch("https://notes.hectabit.org/api/removenote", { method: "POST", body: JSON.stringify({ secretKey: secretkey, @@ -499,7 +499,7 @@ newNote.addEventListener("click", (event) => { } let encryptedName = CryptoJS.AES.encrypt(noteName, password).toString(); - fetch("/api/newnote", { + fetch("https://notes.hectabit.org/api/newnote", { method: "POST", body: JSON.stringify({ secretKey: secretkey, @@ -535,7 +535,7 @@ function downloadObjectAsJson(exportObj, exportName) { function exportNotes() { let noteExport = [] - fetch("/api/exportnotes", { + fetch("https://notes.hectabit.org/api/exportnotes", { method: "POST", body: JSON.stringify({ secretKey: secretkey @@ -594,7 +594,7 @@ removeBox.addEventListener("click", (event) => { if (selectedNote == 0) { displayError("You need to select a note first!") } else { - fetch("/api/removenote", { + fetch("https://notes.hectabit.org/api/removenote", { method: "POST", body: JSON.stringify({ secretKey: secretkey, diff --git a/static/js/signup.js b/static/js/signup.js index dd20dc7..4566a67 100644 --- a/static/js/signup.js +++ b/static/js/signup.js @@ -1,10 +1,10 @@ if (localStorage.getItem("DONOTSHARE-secretkey") !== null) { - window.location.replace("/app") + window.location.replace("../app/index.html") document.body.innerHTML = "Redirecting..." throw new Error(); } if (localStorage.getItem("DONOTSHARE-password") !== null) { - window.location.replace("/app") + window.location.replace("../app/index.html") document.body.innerHTML = "Redirecting..." throw new Error(); } @@ -61,7 +61,7 @@ signupButton.addEventListener("click", (event) => { }; - fetch("/api/signup", { + fetch("https://notes.hectabit.org/api/signup", { method: "POST", body: JSON.stringify({ username: username, @@ -81,7 +81,7 @@ signupButton.addEventListener("click", (event) => { localStorage.setItem("DONOTSHARE-secretkey", responseData["key"]) localStorage.setItem("DONOTSHARE-password", await hashwasm.sha512(password)) - window.location.href = "/app" + window.location.href = "../app/index.html" } else if (response.status == 409) { statusBox.innerText = "Username already taken!" diff --git a/templates/app.html b/templates/app.html index 03caaac..27e5ac0 100644 --- a/templates/app.html +++ b/templates/app.html @@ -6,8 +6,8 @@ - - + + @@ -28,7 +28,7 @@
+ src="../static/svg/add.svg">New note
@@ -46,10 +46,10 @@

Account managment

- - - - + + + +
- + diff --git a/templates/logout.html b/templates/logout.html index c1671f4..80edaf8 100644 --- a/templates/logout.html +++ b/templates/logout.html @@ -11,5 +11,5 @@ Logging out.. localStorage.removeItem("DONOTSHARE-secretkey") localStorage.removeItem("DONOTSHARE-password") localStorage.removeItem("CACHE-username") - window.location.replace("/") + window.location.replace("../index.html") diff --git a/templates/main.html b/templates/main.html index 7131e99..ff22c33 100644 --- a/templates/main.html +++ b/templates/main.html @@ -17,12 +17,12 @@

Burgernotes

A simple note-taking service!


- Open in your browser + Open in your browser - Download for iOS + Download for iOS - +
@@ -37,7 +37,7 @@ diff --git a/templates/privacy.html b/templates/privacy.html index cca9b4f..61e1220 100644 --- a/templates/privacy.html +++ b/templates/privacy.html @@ -6,7 +6,7 @@ - + diff --git a/templates/signup.html b/templates/signup.html index d6b4df8..589e635 100644 --- a/templates/signup.html +++ b/templates/signup.html @@ -6,8 +6,8 @@ - - + + @@ -20,8 +20,8 @@

Please note that it's impossible to reset your password, do not forget it!

-

Already have an account? If so, Login instead!

+

Already have an account? If so, Login instead!

- - + + From eaf04e20f11c2f00d5123106884faf12353ac5ee Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Tue, 27 Feb 2024 17:09:30 +0000 Subject: [PATCH 02/12] Fixed main --- templates/main.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/main.html b/templates/main.html index ff22c33..1a33583 100644 --- a/templates/main.html +++ b/templates/main.html @@ -6,7 +6,7 @@ - + From ba1411eed5d44ea308454a6e9082311e6012e00d Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Tue, 27 Feb 2024 17:11:35 +0000 Subject: [PATCH 03/12] Fixed style.css --- static/css/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/css/style.css b/static/css/style.css index 5d40e2a..1eb19c1 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -170,7 +170,7 @@ body { filter: invert(var(--invertdm)); padding-left: 17.5px; padding-right: 17.5px; - background-image: url("/static/svg/delete.svg"); + background-image: url("../static/svg/delete.svg"); background-position: center; background-repeat: no-repeat; background-size: 55%; From 8af123968a521af5ed2688b31f83180eea68d827 Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Tue, 27 Feb 2024 17:36:42 +0000 Subject: [PATCH 04/12] Fixed content-length --- static/js/login.js | 4 ++-- static/js/main.js | 22 +++++++++++----------- static/js/signup.js | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/static/js/login.js b/static/js/login.js index 7800374..e20da4c 100644 --- a/static/js/login.js +++ b/static/js/login.js @@ -118,7 +118,7 @@ signupButton.addEventListener("click", (event) => { newpass: "null" }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .then((response) => response) @@ -142,7 +142,7 @@ signupButton.addEventListener("click", (event) => { newpass: await hashpass(password) }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .then((response) => response) diff --git a/static/js/main.js b/static/js/main.js index b2fed72..9e19fc0 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -203,7 +203,7 @@ function updateUserInfo() { secretKey: secretkey }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .then((response) => response) @@ -250,7 +250,7 @@ deleteMyAccountButton.addEventListener("click", (event) => { secretKey: secretkey }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .then((response) => response) @@ -273,7 +273,7 @@ sessionManagerButton.addEventListener("click", (event) => { secretKey: secretkey }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .then((response) => response) @@ -314,7 +314,7 @@ sessionManagerButton.addEventListener("click", (event) => { sessionId: responseData[i]["id"] }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .then((response) => response) @@ -365,7 +365,7 @@ function selectNote(nameithink) { noteId: nameithink, }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .catch((error) => { @@ -404,7 +404,7 @@ function selectNote(nameithink) { content: encryptedText, }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .then((response) => response) @@ -431,7 +431,7 @@ function updateNotes() { secretKey: secretkey }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .then((response) => response) @@ -466,7 +466,7 @@ function updateNotes() { noteId: responseData[i]["id"] }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .then((response) => response) @@ -506,7 +506,7 @@ newNote.addEventListener("click", (event) => { noteName: encryptedName, }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .catch((error) => { @@ -541,7 +541,7 @@ function exportNotes() { secretKey: secretkey }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .then((response) => response) @@ -601,7 +601,7 @@ removeBox.addEventListener("click", (event) => { noteId: selectedNote }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .then((response) => response) diff --git a/static/js/signup.js b/static/js/signup.js index 4566a67..9452651 100644 --- a/static/js/signup.js +++ b/static/js/signup.js @@ -68,7 +68,7 @@ signupButton.addEventListener("click", (event) => { password: await hashpass(password) }), headers: { - "Content-type": "application/json; charset=UTF-8" + "Content-Type": "application/json; charset=UTF-8" } }) .then((response) => response) From 0c0f265667e6a899989e40f706744b467e7472ae Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Tue, 27 Feb 2024 17:50:45 +0000 Subject: [PATCH 05/12] Removed useless UTF-8 decleration --- APIDOCS.md | 2 +- static/js/login.js | 10 ++------- static/js/main.js | 55 +++++++++------------------------------------ static/js/signup.js | 5 +---- 4 files changed, 15 insertions(+), 57 deletions(-) diff --git a/APIDOCS.md b/APIDOCS.md index c49dfbc..205c6c2 100644 --- a/APIDOCS.md +++ b/APIDOCS.md @@ -1,7 +1,7 @@ # Burgernotes API docs Use the Burgernotes API to automate tasks, build your own client, and more! -Headers should be: "Content-type: application/json; charset=UTF-8" for all POSTs +Content-type should be "application/json" for all POSTs ## Authentication diff --git a/static/js/login.js b/static/js/login.js index e20da4c..57daff2 100644 --- a/static/js/login.js +++ b/static/js/login.js @@ -116,10 +116,7 @@ signupButton.addEventListener("click", (event) => { password: await hashpass(password), passwordchange: "no", newpass: "null" - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .then((response) => response) .then((response) => { @@ -140,10 +137,7 @@ signupButton.addEventListener("click", (event) => { password: await hashpassold(password), passwordchange: "yes", newpass: await hashpass(password) - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .then((response) => response) .then((response) => { diff --git a/static/js/main.js b/static/js/main.js index 9e19fc0..81cfe62 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -201,10 +201,7 @@ function updateUserInfo() { method: "POST", body: JSON.stringify({ secretKey: secretkey - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .then((response) => response) .then((response) => { @@ -248,10 +245,7 @@ deleteMyAccountButton.addEventListener("click", (event) => { method: "POST", body: JSON.stringify({ secretKey: secretkey - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .then((response) => response) .then((response) => { @@ -271,10 +265,7 @@ sessionManagerButton.addEventListener("click", (event) => { method: "POST", body: JSON.stringify({ secretKey: secretkey - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .then((response) => response) .then((response) => { @@ -312,10 +303,7 @@ sessionManagerButton.addEventListener("click", (event) => { body: JSON.stringify({ secretKey: secretkey, sessionId: responseData[i]["id"] - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .then((response) => response) .then((response) => { @@ -363,10 +351,7 @@ function selectNote(nameithink) { body: JSON.stringify({ secretKey: secretkey, noteId: nameithink, - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .catch((error) => { noteBox.readOnly = true @@ -402,10 +387,7 @@ function selectNote(nameithink) { secretKey: secretkey, noteId: nameithink, content: encryptedText, - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .then((response) => response) .then((response) => { @@ -429,10 +411,7 @@ function updateNotes() { method: "POST", body: JSON.stringify({ secretKey: secretkey - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .then((response) => response) .then((response) => { @@ -464,10 +443,7 @@ function updateNotes() { body: JSON.stringify({ secretKey: secretkey, noteId: responseData[i]["id"] - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .then((response) => response) .then((response) => { @@ -504,10 +480,7 @@ newNote.addEventListener("click", (event) => { body: JSON.stringify({ secretKey: secretkey, noteName: encryptedName, - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .catch((error) => { displayError("Failed to create new note, please try again later...") @@ -539,10 +512,7 @@ function exportNotes() { method: "POST", body: JSON.stringify({ secretKey: secretkey - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .then((response) => response) .then((response) => { @@ -599,10 +569,7 @@ removeBox.addEventListener("click", (event) => { body: JSON.stringify({ secretKey: secretkey, noteId: selectedNote - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .then((response) => response) .then((response) => { diff --git a/static/js/signup.js b/static/js/signup.js index 9452651..45b424a 100644 --- a/static/js/signup.js +++ b/static/js/signup.js @@ -66,10 +66,7 @@ signupButton.addEventListener("click", (event) => { body: JSON.stringify({ username: username, password: await hashpass(password) - }), - headers: { - "Content-Type": "application/json; charset=UTF-8" - } + }) }) .then((response) => response) .then((response) => { From 007e42bf7d59f462fa31e15484f3da562c03d3f6 Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Tue, 27 Feb 2024 17:54:40 +0000 Subject: [PATCH 06/12] FIXED * --- main | 9 +++++++-- static/js/main.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/main b/main index db096f5..a719db8 100644 --- a/main +++ b/main @@ -97,25 +97,29 @@ def check_username_taken(username): return post["id"] # Main page +@app.route("/index.html") @app.route("/") async def main(): return await render_template("main.html") # Web app +@app.route("/app/index.html") @app.route("/app") async def webapp(): return await render_template("app.html") # Login and signup +@app.route("/signup/index.html") @app.route("/signup") async def signup(): return await render_template("signup.html") -@app.route("/login") +@app.route("/login/index.html") async def login(): return await render_template("login.html") # Privacy policy +@app.route("/privacy/index.html") @app.route("/privacy") async def privacy(): return await render_template("privacy.html") @@ -500,7 +504,8 @@ def listusers(secretkey): else: return redirect("/") -@app.route("/api/logout") +@app.route("/logout/index.html") +@app.route("/logout") async def apilogout(): return await render_template("logout.html") diff --git a/static/js/main.js b/static/js/main.js index 81cfe62..268d7a0 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -211,7 +211,7 @@ function updateUserInfo() { closeErrorButton.classList.add("hidden") usernameBox.innerText = "" setTimeout(function () { - window.location.replace("https://notes.hectabit.org/api/logout") + window.location.replace("../logout/index.html") }, 2500); } else { let responseData = await response.json() From 4255a3f107b89355341372e8f8553c8b36605161 Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Tue, 27 Feb 2024 17:55:47 +0000 Subject: [PATCH 07/12] Fixed logout --- static/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/main.js b/static/js/main.js index 268d7a0..2c5de4b 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -233,7 +233,7 @@ usernameBox.addEventListener("click", (event) => { updateUserInfo() }); logOutButton.addEventListener("click", (event) => { - window.location.replace("https://notes.hectabit.org/api/logout") + window.location.replace("/logout/index.html") }); exitThing.addEventListener("click", (event) => { optionsDiv.classList.add("hidden") From 2c106e4dbb580cfda9c1ebc7bcfca9a3e882e177 Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Tue, 27 Feb 2024 18:03:05 +0000 Subject: [PATCH 08/12] Revert "Removed useless UTF-8 decleration" This reverts commit 0c0f265667e6a899989e40f706744b467e7472ae. --- APIDOCS.md | 2 +- static/js/login.js | 10 +++++++-- static/js/main.js | 55 ++++++++++++++++++++++++++++++++++++--------- static/js/signup.js | 5 ++++- 4 files changed, 57 insertions(+), 15 deletions(-) diff --git a/APIDOCS.md b/APIDOCS.md index 205c6c2..c49dfbc 100644 --- a/APIDOCS.md +++ b/APIDOCS.md @@ -1,7 +1,7 @@ # Burgernotes API docs Use the Burgernotes API to automate tasks, build your own client, and more! -Content-type should be "application/json" for all POSTs +Headers should be: "Content-type: application/json; charset=UTF-8" for all POSTs ## Authentication diff --git a/static/js/login.js b/static/js/login.js index 57daff2..e20da4c 100644 --- a/static/js/login.js +++ b/static/js/login.js @@ -116,7 +116,10 @@ signupButton.addEventListener("click", (event) => { password: await hashpass(password), passwordchange: "no", newpass: "null" - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .then((response) => response) .then((response) => { @@ -137,7 +140,10 @@ signupButton.addEventListener("click", (event) => { password: await hashpassold(password), passwordchange: "yes", newpass: await hashpass(password) - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .then((response) => response) .then((response) => { diff --git a/static/js/main.js b/static/js/main.js index 2c5de4b..11d5b18 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -201,7 +201,10 @@ function updateUserInfo() { method: "POST", body: JSON.stringify({ secretKey: secretkey - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .then((response) => response) .then((response) => { @@ -245,7 +248,10 @@ deleteMyAccountButton.addEventListener("click", (event) => { method: "POST", body: JSON.stringify({ secretKey: secretkey - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .then((response) => response) .then((response) => { @@ -265,7 +271,10 @@ sessionManagerButton.addEventListener("click", (event) => { method: "POST", body: JSON.stringify({ secretKey: secretkey - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .then((response) => response) .then((response) => { @@ -303,7 +312,10 @@ sessionManagerButton.addEventListener("click", (event) => { body: JSON.stringify({ secretKey: secretkey, sessionId: responseData[i]["id"] - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .then((response) => response) .then((response) => { @@ -351,7 +363,10 @@ function selectNote(nameithink) { body: JSON.stringify({ secretKey: secretkey, noteId: nameithink, - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .catch((error) => { noteBox.readOnly = true @@ -387,7 +402,10 @@ function selectNote(nameithink) { secretKey: secretkey, noteId: nameithink, content: encryptedText, - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .then((response) => response) .then((response) => { @@ -411,7 +429,10 @@ function updateNotes() { method: "POST", body: JSON.stringify({ secretKey: secretkey - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .then((response) => response) .then((response) => { @@ -443,7 +464,10 @@ function updateNotes() { body: JSON.stringify({ secretKey: secretkey, noteId: responseData[i]["id"] - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .then((response) => response) .then((response) => { @@ -480,7 +504,10 @@ newNote.addEventListener("click", (event) => { body: JSON.stringify({ secretKey: secretkey, noteName: encryptedName, - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .catch((error) => { displayError("Failed to create new note, please try again later...") @@ -512,7 +539,10 @@ function exportNotes() { method: "POST", body: JSON.stringify({ secretKey: secretkey - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .then((response) => response) .then((response) => { @@ -569,7 +599,10 @@ removeBox.addEventListener("click", (event) => { body: JSON.stringify({ secretKey: secretkey, noteId: selectedNote - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .then((response) => response) .then((response) => { diff --git a/static/js/signup.js b/static/js/signup.js index 45b424a..9452651 100644 --- a/static/js/signup.js +++ b/static/js/signup.js @@ -66,7 +66,10 @@ signupButton.addEventListener("click", (event) => { body: JSON.stringify({ username: username, password: await hashpass(password) - }) + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } }) .then((response) => response) .then((response) => { From b4e63d2bbfb5d73293ac3a29cb9d448413ebe834 Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Tue, 27 Feb 2024 18:18:00 +0000 Subject: [PATCH 09/12] Dumb serverside hack --- main | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main b/main index a719db8..3ff4fcc 100644 --- a/main +++ b/main @@ -98,28 +98,39 @@ def check_username_taken(username): # Main page @app.route("/index.html") +async def mainrdir(): + return redirect("/", code=302) @app.route("/") async def main(): return await render_template("main.html") # Web app @app.route("/app/index.html") +async def apprdir(): + return redirect("/app", code=302) @app.route("/app") async def webapp(): return await render_template("app.html") # Login and signup @app.route("/signup/index.html") +async def signup(): + return redirect("/signup", code=302) @app.route("/signup") async def signup(): return await render_template("signup.html") @app.route("/login/index.html") +async def loginrdir(): + return redirect("/login", code=302") +@app.route("login") async def login(): return await render_template("login.html") # Privacy policy @app.route("/privacy/index.html") +async def privacyrdir(): + return redirect("/privacy", code=302) @app.route("/privacy") async def privacy(): return await render_template("privacy.html") @@ -505,6 +516,8 @@ def listusers(secretkey): return redirect("/") @app.route("/logout/index.html") +async def logoutrdir(): + return redirect("/logout", code=302) @app.route("/logout") async def apilogout(): return await render_template("logout.html") From 76266140a00cd2884bc5b76daf26c9b051e4a72f Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Tue, 27 Feb 2024 18:18:24 +0000 Subject: [PATCH 10/12] Fix --- main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main b/main index 3ff4fcc..378f693 100644 --- a/main +++ b/main @@ -122,7 +122,7 @@ async def signup(): @app.route("/login/index.html") async def loginrdir(): - return redirect("/login", code=302") + return redirect("/login", code=302) @app.route("login") async def login(): return await render_template("login.html") From 5622ebd1a1255cb6baf07d019eacfca4c8a1e75b Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Tue, 27 Feb 2024 18:18:47 +0000 Subject: [PATCH 11/12] Fix --- main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main b/main index 378f693..1c96f24 100644 --- a/main +++ b/main @@ -114,7 +114,7 @@ async def webapp(): # Login and signup @app.route("/signup/index.html") -async def signup(): +async def signuprdir(): return redirect("/signup", code=302) @app.route("/signup") async def signup(): From 15bd8b3d3bf5642f16d4fbf637968a3b47a1d0aa Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Tue, 27 Feb 2024 18:19:10 +0000 Subject: [PATCH 12/12] Silly --- main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main b/main index 1c96f24..8422dbc 100644 --- a/main +++ b/main @@ -123,7 +123,7 @@ async def signup(): @app.route("/login/index.html") async def loginrdir(): return redirect("/login", code=302) -@app.route("login") +@app.route("/login") async def login(): return await render_template("login.html")