Delete account in sidebar
This commit is contained in:
@@ -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 })
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
Reference in New Issue
Block a user