Auth basic working - unsafe
This commit is contained in:
@@ -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 !== "")
|
||||
|
||||
Reference in New Issue
Block a user