burgerauth/templates/acct.html

62 lines
2.5 KiB
HTML
Raw Normal View History

2024-05-16 17:34:51 +01:00
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="/static/css/style.css" media="">
2024-05-16 17:34:51 +01:00
<script src="/static/js/dashboard.js"></script>
<title>Dashboard</title>
</head>
<body style="background-color: transparent;">
2024-05-16 17:34:51 +01:00
<script>
async function deleteacct() {
2024-05-18 00:55:45 +01:00
if (confirm("Are you SURE you would like to delete your account forever?") == true) {
await fetch(remote + "/api/deleteaccount", {
method: "POST",
body: JSON.stringify({
"secretKey": localStorage.getItem("DONOTSHARE-secretkey")
}),
headers: {
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)
.then((response) => {
async function doStuff() {
if (response.status === 200) {
parent.window.location.href = '/logout';
}
}
2024-05-18 00:55:45 +01:00
doStuff()
});
}
}
fetch("/api/userinfo", {
2024-05-16 17:34:51 +01:00
method: "POST",
body: JSON.stringify({
"secretKey": localStorage.getItem("DONOTSHARE-secretkey")
}),
headers: {
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => {
async function doStuff() {
const data = await response.json()
2024-05-16 17:34:51 +01:00
if (response.status === 200) {
document.getElementById("namebox").innerText = "Username: " + data.username;
document.getElementById("datebox").innerText = "Account created: " + new Date(data.created * 1000).toLocaleString();
2024-05-16 17:34:51 +01:00
}
}
doStuff()
});
</script>
<div class="newoauth" style="margin: 0;">
<h2>Account settings</h2>
<p id="namebox">Loading...</p>
<p id="datebox"></p>
2024-05-16 17:34:51 +01:00
<button onclick="parent.window.location.href = '/logout';">Logout</button><br style="">
<button onclick="deleteacct()" style="margin-top: 5px;">Delete Account</button>
</div>
</body>
</html>