www.spaceplanner.app

Web client to the spaceplanner API
git clone git://jacobedwards.org/www.spaceplanner.app
Log | Files | Refs

commit 0176ee82325add8f869b56b0f160187842c1c757
parent e128b51f7f9cf1e830bbb4ff2883f1f061767a8d
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Fri, 11 Oct 2024 11:46:27 -0700

Utilize :user substitution in various pages

Diffstat:
Mfiles/services/main.js | 2+-
Mfiles/settings/main.js | 8++++----
Mfiles/settings/verify-email/main.js | 2+-
3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/files/services/main.js b/files/services/main.js @@ -18,7 +18,7 @@ function chooseService(service) { window.location.href = "/register" } - api.fetch("POST", "users/" + localStorage.getItem("username") + "/services/checkout", + api.fetch("POST", "users/:user/services/checkout", { prices: [ service.prices[0].id ] }).then(function(body) { console.warn(body) window.location.href = body.url diff --git a/files/settings/main.js b/files/settings/main.js @@ -14,7 +14,7 @@ function main() { let errfunc = function(err) { etc.error("Unable to get settings: " + err, document.querySelector("#settings")) } api.fetch("GET", "settings") .then(function(params) { - api.fetch("GET", "users/" + localStorage.getItem("username") + "/settings") + api.fetch("GET", "users/:user/settings") .then(function(current) { show_settings(current, params) }) @@ -58,7 +58,7 @@ function delete_form() { } function delete_user() { - api.fetch("DELETE", "users/" + localStorage.getItem("username")) + api.fetch("DELETE", "users/:user") .then(function() { api.update_token(null) document.location.href = "/" @@ -134,7 +134,7 @@ function update_settings(current, params) { if (patch.length == 0) { return } - api.fetch("PATCH", "users/" + localStorage.getItem("username") + "/settings", patch) + api.fetch("PATCH", "users/:user/settings", patch) .then(function(updated) { for (let k in updated) { current[k] = updated[k] @@ -151,7 +151,7 @@ function update_verified_email() { throw new Error("Expected email setting") } - api.fetch("GET", "users/" + localStorage.getItem("username") + "/email/verified") + api.fetch("GET", "users/:user/email/verified") .then(function(verified) { update_info("Email", verified) let old_warning = document.getElementById("unverified_email_warning") diff --git a/files/settings/verify-email/main.js b/files/settings/verify-email/main.js @@ -41,7 +41,7 @@ function codeForm() { form.addEventListener("submit", function(event) { event.preventDefault() - api.fetch("POST", "users/" + localStorage.getItem("username") + "/email/code", { code: code.value }) + api.fetch("POST", "users/:user/email/code", { code: code.value }) .then(function(body) { if (!body.valid) { etc.error("That was not the correct code, please try again.", form)