Delete account in sidebar
This commit is contained in:
@@ -21,6 +21,8 @@ class Sidebar extends Shadow {
|
||||
global.onLogout()
|
||||
$("home-").closeSidebar();
|
||||
return
|
||||
} else if (this.innerText === "Delete account") {
|
||||
$("sidebar-").deleteAccount();
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -63,6 +65,7 @@ class Sidebar extends Shadow {
|
||||
})
|
||||
|
||||
this.SidebarItem("Logout")
|
||||
this.SidebarItem("Delete account")
|
||||
})
|
||||
.gap(1, em)
|
||||
.paddingTop(15, vh)
|
||||
@@ -82,6 +85,26 @@ class Sidebar extends Shadow {
|
||||
$("appwindowcontainer-").openProfile()
|
||||
$("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)
|
||||
Reference in New Issue
Block a user