Made the account manager get the name and date created of the user

This commit is contained in:
Tracker-Friendly 2024-05-16 17:48:35 +01:00
parent 153b53f48a
commit a5b32c32b8
1 changed files with 27 additions and 7 deletions

View File

@ -6,8 +6,28 @@
</head> </head>
<body> <body>
<script> <script>
async function deleteacct() { async function deleteacct() {
await fetch(remote + "/api/deleteaccount", { 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';
}
}
doStuff()
});
}
fetch("/api/userinfo", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
"secretKey": localStorage.getItem("DONOTSHARE-secretkey") "secretKey": localStorage.getItem("DONOTSHARE-secretkey")
@ -16,21 +36,21 @@
"Content-Type": "application/json; charset=UTF-8" "Content-Type": "application/json; charset=UTF-8"
} }
}) })
.then((response) => response)
.then((response) => { .then((response) => {
async function doStuff() { async function doStuff() {
const data = await response.json()
if (response.status === 200) { if (response.status === 200) {
parent.window.location.href = '/logout'; document.getElementById("namebox").innerText = "Username: " + data.username;
document.getElementById("datebox").innerText = "Account created: " + new Date(data.created * 1000).toLocaleString();
} }
} }
doStuff() doStuff()
}); });
}
</script> </script>
<div class="newoauth" style="margin: 0;"> <div class="newoauth" style="margin: 0;">
<h2>Account settings</h2> <h2>Account settings</h2>
<p>Name: </p> <p id="namebox">Loading...</p>
<p>Created: </p> <p id="datebox"></p>
<button onclick="parent.window.location.href = '/logout';">Logout</button><br style=""> <button onclick="parent.window.location.href = '/logout';">Logout</button><br style="">
<button onclick="deleteacct()" style="margin-top: 5px;">Delete Account</button> <button onclick="deleteacct()" style="margin-top: 5px;">Delete Account</button>
</div> </div>