get tables on admin login

This commit is contained in:
Iris Lightshard 2023-01-26 21:44:03 -07:00
parent 50ea1c2b12
commit b89711bbf7
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
4 changed files with 24 additions and 7 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
felt
go.work
user.db
mongodb/data/*
mongodb/.env

2
go.mod
View file

@ -6,7 +6,7 @@ require (
go.mongodb.org/mongo-driver v1.11.0
golang.org/x/time v0.1.0
nhooyr.io/websocket v1.8.7
nilfm.cc/git/quartzgun v0.2.0
nilfm.cc/git/quartzgun v0.2.2
)
require (

2
go.sum
View file

@ -105,5 +105,3 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
nilfm.cc/git/quartzgun v0.2.0 h1:JJjkCbRLaMmfGLe5GQHWhBkkY6Is0roTMyWC76VtBPI=
nilfm.cc/git/quartzgun v0.2.0/go.mod h1:/DDvt1DtzNuUf3HHaP29WMei/kkdaRW+ySmEzybvVto=

View file

@ -1,5 +1,22 @@
let adminToken = null;
async function getTables() {
try {
const headers = new Headers();
self.set('Authorization', 'Bearer ' + adminToken.access_token);
const res = await fetch('/admin/api/table/', {
method: 'GET',
headers: headers
});
if (res.ok) {
} else {
console.log(res);
console.log(await res.headers.get("Quartzgun-Error"));
}
} catch {
}
}
async function doLogin() {
const adminUsrInput = document.getElementById("input_admin_usr");
const adminPassInput = document.getElementById("input_admin_pass");
@ -7,12 +24,13 @@ async function doLogin() {
if (adminUsrInput && adminPassInput) {
adminToken = await getAdminToken(adminUsrInput.value, adminPassInput.value);
console.log(adminToken);
if (adminToken) {
// render admin interface
getTables();
} else {
if (errDiv) {
errDiv.innerHTML = "Incorrect credentials";
}
if (errDiv) {
errDiv.innerHTML = "Incorrect credentials";
}
}
}
}