Auth basic working - unsafe

This commit is contained in:
SinTan1729
2023-04-08 02:52:16 -05:00
parent 7d5ff40893
commit 34b2b116ba
5 changed files with 294 additions and 19 deletions

View File

@@ -9,8 +9,22 @@ const getSiteUrl = async () => await fetch("/api/siteurl")
}
});
const auth_fetch = async (link) => {
let reply = await fetch(link).then(res => res.text());
if (reply == "logged_out") {
pass = prompt("Please enter passkey to access this website");
await fetch("/api/login", {
method: "POST",
body: pass
});
return auth_fetch(link);
} else {
return reply;
}
}
const refreshData = async () => {
let data = await fetch("/api/all").then(res => res.text());
let data = await auth_fetch("/api/all");
data = data
.split("\n")
.filter(line => line !== "")