get tables on admin login
This commit is contained in:
parent
50ea1c2b12
commit
b89711bbf7
4 changed files with 24 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
felt
|
felt
|
||||||
|
go.work
|
||||||
user.db
|
user.db
|
||||||
mongodb/data/*
|
mongodb/data/*
|
||||||
mongodb/.env
|
mongodb/.env
|
2
go.mod
2
go.mod
|
@ -6,7 +6,7 @@ require (
|
||||||
go.mongodb.org/mongo-driver v1.11.0
|
go.mongodb.org/mongo-driver v1.11.0
|
||||||
golang.org/x/time v0.1.0
|
golang.org/x/time v0.1.0
|
||||||
nhooyr.io/websocket v1.8.7
|
nhooyr.io/websocket v1.8.7
|
||||||
nilfm.cc/git/quartzgun v0.2.0
|
nilfm.cc/git/quartzgun v0.2.2
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -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=
|
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 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=
|
||||||
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
|
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=
|
|
||||||
|
|
|
@ -1,5 +1,22 @@
|
||||||
let adminToken = null;
|
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() {
|
async function doLogin() {
|
||||||
const adminUsrInput = document.getElementById("input_admin_usr");
|
const adminUsrInput = document.getElementById("input_admin_usr");
|
||||||
const adminPassInput = document.getElementById("input_admin_pass");
|
const adminPassInput = document.getElementById("input_admin_pass");
|
||||||
|
@ -7,12 +24,13 @@ async function doLogin() {
|
||||||
|
|
||||||
if (adminUsrInput && adminPassInput) {
|
if (adminUsrInput && adminPassInput) {
|
||||||
adminToken = await getAdminToken(adminUsrInput.value, adminPassInput.value);
|
adminToken = await getAdminToken(adminUsrInput.value, adminPassInput.value);
|
||||||
|
console.log(adminToken);
|
||||||
if (adminToken) {
|
if (adminToken) {
|
||||||
// render admin interface
|
getTables();
|
||||||
} else {
|
} else {
|
||||||
if (errDiv) {
|
if (errDiv) {
|
||||||
errDiv.innerHTML = "Incorrect credentials";
|
errDiv.innerHTML = "Incorrect credentials";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue