Delete account in sidebar

This commit is contained in:
2026-03-24 16:39:53 -04:00
parent 40b0855ca5
commit 1c61a4d202
2 changed files with 24 additions and 1 deletions

View File

@@ -82,7 +82,7 @@ class EnterCode extends Shadow {
console.log("submit") console.log("submit")
const res = await fetch(`${util.HOST}/auth/joincode`, { const res = await fetch(`${util.HOST}/auth/joincode`, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json', "Accept": "application/json" }, headers: { 'Content-Type': 'application/json', "Accept": "application/json", "X-Client": "mobile" },
body: JSON.stringify({ code: this.$("input").value }) body: JSON.stringify({ code: this.$("input").value })
}); });

View File

@@ -21,6 +21,8 @@ class Sidebar extends Shadow {
global.onLogout() global.onLogout()
$("home-").closeSidebar(); $("home-").closeSidebar();
return return
} else if (this.innerText === "Delete account") {
$("sidebar-").deleteAccount();
} }
} }
}) })
@@ -63,6 +65,7 @@ class Sidebar extends Shadow {
}) })
this.SidebarItem("Logout") this.SidebarItem("Logout")
this.SidebarItem("Delete account")
}) })
.gap(1, em) .gap(1, em)
.paddingTop(15, vh) .paddingTop(15, vh)
@@ -82,6 +85,26 @@ class Sidebar extends Shadow {
$("appwindowcontainer-").openProfile() $("appwindowcontainer-").openProfile()
$("home-").closeSidebar(); $("home-").closeSidebar();
} }
async deleteAccount() {
try {
const res = await util.authFetch(`${util.HOST}/auth/delete`, {
method: "DELETE",
credentials: "include",
headers: {
"X-Client": "mobile",
"Content-Type": "application/json",
"Accept": "application/json"
},
body: JSON.stringify({ memberId: global.profile.id })
});
if (!res.ok) return;
global.onLogout()
} catch (err) {
console.error(err)
}
}
} }
register(Sidebar) register(Sidebar)