Auth basic working - unsafe
This commit is contained in:
1 parent
7d5ff40893
commit
34b2b116ba
5 files changed
+294
-19
No files matched your search
@@ -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